File:  [OS/2 SDKs] / os2sdk / demos / examples / move / move.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Thu Aug 9 12:26:09 2018 UTC (7 years, 9 months ago) by root
Branches: msft, MAIN
CVS tags: os2sdk-1988, HEAD
Microsoft OS/2 SDK 03-01-1988

/*
 * Program to demonstrate DosFindFirst and DosMove.
 *
 * Compile as: cl -AL -G0 -Lp move.c
 *
 * Created by Microsoft Corp. 1987
 */

#define INCL_DOSFILEMGR

#include <os2def.h>
#include <bsedos.h>
#include <stdio.h>
#include <string.h>

main (argc, argv)
	int	argc ;
	char	*argv [] ;
	{
	FILEFINDBUF  findbuf ;
	HDIR	handle = 0xFFFF ;
	UINT	count  = 1 ;
	char	oldpath [81], newpath [81], oldspec [81], newspec [81] ;
	UINT	code ;
	char	*ptr ;

	if (argc < 3) {
		printf ("Syntax: MOVE filespec directory") ;
		exit (1) ;
	}

	strcpy (oldpath, strlwr (argv [1])) ;

	if (NULL != (ptr = strrchr (oldpath, '\\')) ||
			NULL != (ptr = strrchr (oldpath, ':')))
		*(ptr + 1) = '\0' ;
	else
		*oldpath = '\0' ;

	strcpy (newpath, strlwr (argv [2])) ;

	if (newpath [strlen (newpath) - 1] != '\\')
		strcat (newpath, "\\") ;

	DosFindFirst (argv [1], &handle, 7, &findbuf,
			sizeof (findbuf), &count, 0L) ;

	while(count) {
		strcpy (oldspec, oldpath) ;
		strcat (oldspec, findbuf.achName) ;

		strcpy (newspec, newpath) ;
		strcat (newspec, findbuf.achName) ;

		code = DosMove (oldspec, newspec, 0L) ;

		printf ("%s --> %s %s\n", oldspec, newspec,
				code ? "FAILED" : "") ;

		DosFindNext (handle, &findbuf, sizeof (findbuf), &count) ;
	}

	DosFindClose (handle) ;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.