File and Directory Management

Reference Section

_access_f
_ch_dir
_exist_f
_expand_path
_find_first
_find_next
_fix_filename
_fix_path
_get_curdir
_get_cwd
_get_drive
_getmode_f
_merge_drive
_merge_drvpath
_merge_ext
_merge_fname
_merge_fnamext
_merge_path
_mk_dir
_mk_temp
_remove_f
_rename_f
_rm_dir
_search_path
_set_drive
_setmode_f
_split_drive
_split_drvpath
_split_ext
_split_fname
_split_fnamext
_split_path
_term_path

_access_f


Descrip
Determines the accessibility of a file or directory.

Syntax
#include <filedir.h>
int _access_f(const char *name);

Returns
1 if name exists and has read/write permission or is a directory.

0 if name exists and has read-only permission.

-1 if name does not exist or an error occurred.
e_code error code

Notes
This function determines if name exists. If name is a file, this function also determines if the file is read-write or read-only. 1 is returned if name refers to a directory or if it is a file with read/write permission. 0 is returned if name is a file with read-only permission. -1 is returned if name does not exist or the drive or path specified is invalid. name may include a drive specifier and a path.

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   char buffer[13];
	   if (_access_f (buffer))
	   {
	      /* Does not have read/write permission */
	   } else
	   {
	      /* Has read/write permission */
	   }
	}

Inline Assembly Example
	#include <inline.h>
	{
	char buffer[13] = "file.dat";
	   ...
	   lea si,buffer
	   access_f ();
	    je access_f_010/* if read/write permission */
	    ja access_f_020/* if read-only permission */
	   ... 	 	/* if an error occurred */
	   jmp short access_f_100
	access_f_010:	 	/* read/write permission */
	   ...
	   jmp short access_f_100
	access_f_020:	 	/* read-only permission */
	   ...
	access_f_100:	 	/* done... */
	   ...
	}

Source file _FDACCES.ASM ASM equiv ACCESS_F
See also
_exist_f, _find_first, _getmode_f

_ch_dir


Descrip
Changes the current directory.

Syntax
#include <filedir.h>
int _ch_dir(const char *path);

Returns
0 if the directory was successfully changed.

-1 if the function was unsuccessful.
e_code error code

Notes
This function changes the current working directory to path. The change takes place on the drive specified in path. If no drive specifier is provided in path, the change takes place on the current drive. If path does not include an explicit path specifier (i.e., the default path is specified), no change takes place and 0 is returned.

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   if (_ch_dir(".") == -1)
	   {
	      /* Handle the error */
	   }
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char *dir= "D:\\TEMP";
	   mov si,dir
	   ch_dir ();
	    jncch_dir_010/* If successful */
	   ... 	 	/* if an error occurred */
	ch_dir_010:
	   ...
	}

Source file _FDCHDIR.ASM ASM equiv CH_DIR
See also
_get_cwd, _mk_dir, _rm_dir

_exist_f


Descrip
Determines if a file, directory, or volume label exists and if its attributes match those provided.

Syntax
#include <filedir.h>
int _exist_f(const char *name, int *attr);

Returns
0 if name exists and its attributes match those provided.
attr attributes for name

1 if name exists, but its attributes do not match those provided.
attr attributes for name

-1 if name does not exist or an error occurred.
e_code error code (E_PNOTFOUND if the file, directory, or volume label does not exist)

Notes
This function determines if name exists and if its attributes match attr. name may be a file, directory, or volume label. 0 is returned if name exists and its attributes match the attributes specified in attr (see below) as follows: 1) If only FA_NORM is specified, name must be an ordinary or ordinary read-only file. If only FA_ARCH or FA_NORM+FA_ARCH is specified, name must be an ordinary or ordinary read-only file with its archive bit set. 2) If only FA_RDONLY is specified, name must be an ordinary read-only file. If only FA_RDONLY+FA_ARCH is specified, name must be an ordinary read-only file with its archive bit set. 3) If any other combination of attributes is specified, FA_NORM is ignored and all other specified attributes must match. Unspecified attributes are not considered. If name exists but none of the above conditions are true, 1 is returned.

attr is created by bitwise ORing together the symbolic constants defined in FILECNTL.H (automatically included from FILEDIR.H) as follows:

FA_NORM (0x0000) Ordinary
FA_RDONLY(0x0001) Read-only
FA_HIDDEN(0x0002) Hidden
FA_SYSTEM(0x0004) System
FA_LABEL (0x0008) Volume label
FA_SUBDIR(0x0010) Directory
FA_ARCH (0x0020) Archive

e_code may be obtained using the get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   int cond = FA_NORM;
	   char filename[13];
	   ...
	   if (!_exist_f (filename, &cond) || cond)
	   {
	      /* Handle the error */
	   }
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	char filename[13] = "file.dat";
	      ...
	   lea si,filename
	   mov ax,FA_NORM/* AX=file attrs to look for */
	   exist_f ();
	    ja exist_f_010/* if attributes didn't match */
	    jb exist_f_020/* an error occurred */
	   ... 	 	/* if attributes match */
	   jmp short exist_f_030

	exist_f_010:
	   ... 	 	/* Attributes don't match */
	   jmp short exist_f_030

	exist_f_020:
	   ... 	 	/* file doesn't exist or error */
	exist_f_030:
	   ...
	}

Source file _FDEXIST.ASM ASM equiv EXIST_F
See also
_access_f, _find_first, _getmode_f

_expand_path


Descrip
Expands a partial path to a full path.

Syntax
#include <filedir.h>
int _expand_path(char *pathname);

Returns
0 if pathname was a valid path.
pathname full path

1 if pathname was a valid path plus filename.
pathname full path plus filename

-1 if pathname was not a valid path or path plus filename.
pathname original pathname string
e_code error code

Notes
This function expands the partial path in pathname to a full path including a drive specifier. pathname may consist of a drive specifier and/or a path and/or a filename. The full path is returned in pathname in all-uppercase characters.

If pathname is a filename only, the active drive and current working directory are returned affixed to the front of the filename, and 1 is returned. If pathname is a NULL string, the active drive and current working directory are returned in pathname, and 0 is returned. -1 is returned if pathname is invalid. If 1 is returned, the last element of the returned pathname is not a valid subdirectory and is assumed to be a filename. A return value of 1 is impossible if pathname is terminated with a backslash character.

This function assumes that any drive specifier in pathname consists of only a single drive letter followed by a colon. Network-type drive specifiers such as "SYS:" are not recognized.

This function uses approximately 180 bytes of stack space.

e_code may be obtained using the get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   char buffer[50];
	   ...
	   switch (_expand_path (buffer))
	   {
	      case 1:
	         /* Pathname is a valid path plus filename */
	         break;
	      case 0:
	         /* Pathname is a valid path */
	         break;
	      case -1:
	         /* Pathname is not a valid path or filename */
	         break;
	   }
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[50] = "file.dat";
	   ...
	   lea si,buffer
	   expand_path ();
	    ja expand_p_010/* path + filename */
	    jb expand_p_020/* error or file doesn't exist */
	   ... 	 	/* filename was a path */
	   jmp short expand_p_030
	expand_p_010:
	   ... 	 	/* filename = path + filename */
	   jmp short expand_p_030
	expand_p_020:
	   ... 	 	/* file doesn't exist or error */
	expand_p_030:
	   ...
	}

Source file _FDEXPND.ASM ASM equiv EXPAND_PATH
See also
_fix_filename

_find_first


Descrip
Finds the first file which matches the name and attributes provided.

Syntax
#include <filedir.h>
int _find_first(const char *name, fbuf far *buffer, int attr);

Returns
0 if a matching file was found.
buffer information about the matching file

1 if no matching file was found or if the path was not found.
e_code error code (E_PNOTFOUND)

-1 if an error occurred.
e_code error code

Notes
This function finds the first file that matches name with attributes matching attr. name may include the "*" and "?" wildcard characters. attr is created by bitwise ORing together symbolic constants from the list below. These constants are defined in FILECNTL.H and are automatically included from FILEDIR.H:

FA_NORM (0x0000) Ordinary
FA_HIDDEN(0x0002) Hidden
FA_SYSTEM(0x0004) System
FA_LABEL (0x0008) Volume label
FA_SUBDIR(0x0010) Directory

If only the FA_NORM flag is specified, only ordinary files are found.

If any combination of the FA_HIDDEN, FA_SYSTEM, or FA_SUBDIR flags are specified, _find_first will match all ordinary files as well as any files with these attributes (this is the way the DOS Find First function call works). If the FA_LABEL flag is used, only volume labels are found. Note that the FA_RDONLY and FA_ARCH flags do not apply to this function.

1 is returned if a matching path and/or file does not exist. -1 is returned if an error occurred. 0 is returned and buffer is filled in with the file information if a matching file is found.

buffer is a structure of type fbuf, which is defined in FILEDIR.H as follows:

typedef struct {
char reserved[21];/* reserved by DOS */
char attr; /* file attributes */
int time; /* file time */
int date; /* file date */
long size; /* file size */
char name[13];/* ASCIIZ filename */
} fbuf;

A return value of 1 indicates nonexistent paths as well as nonexistent files because DOS does not properly differentiate these cases. To determine if a path exists, use _exist_f or _expand_path.

Note that the date and time values returned by this function use the same format returned by _getftime_h, _merge_time and _merge_date.

WARNING! After _find_first has been called, changes to the DTA must be made using _set_dta. Failure to comply with this rule will cause subsequent _find_next calls to fail.

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   fbuf filebuf;
	   int code;
	   code = _find_first ("*.c", &filebuf, FA_NORM);
	   if (code == -1)
	   {
	      /* Handle the error */
	   } else if (code == 1)
	   {
	      /* handle no matching files */
	   } else
	   {
	      do {
	         ...
	      } while (!_find_next (&filebuf));
	      ...
	   }
	}

Inline Assembly Example
	#include <inline.h>
	{
	   fbuf filebuf;
	   char *filespec = "*.c";
	   ...
	   mov si,filespec
	   pushss
	   pop es	 	/* ES = SS */
	   lea di,filebuf
	   mov ax,FA_NORM/* AX = attributes to look for */
	   find_first ();
	    ja find_first_060/* if no matching files found */
	    jb find_first_040/* if an error occurred */
	find_first_020:
	   ... 	 /* process the matching files here... */
	   find_next ();
	    je find_first_020/* if a matching file was found */
	    ja find_first_060/* if no matching files found */
	find_first_040:
	   ... 	 	/* DOS error ... */
	   jmp find_first_080
	find_first_060:
	   ... 	 	/* no more matching files */
	find_first_080:
	   ...
	}

Source file _FDFINDF.ASM ASM equiv FIND_FIRST
See also
_exist_f, _find_next

_find_next


Descrip
Finds the next file which matches the name and attributes specified with a previous _find_first.

Syntax
#include <filedir.h>
int _find_next(fbuf far *buffer);

Returns
0 if a matching file was found.
buffer information about the matching file

1 if no more matching files exist.
e_code error code (E_NMOREFILE)

-1 if an error occurred.
e_code error code

Notes
This function finds the next file which matches the name and attributes that were preserved in buffer by a previous call to _find_first. 1 is returned if no more matching files exist. -1 is returned if an error occurred. 0 is returned and buffer is filled in with the file information if a matching file is found. buffer is a structure of type fbuf, which is defined in FILECNTL.H (automatically included from FILEDIR.H) as follows:

typedef struct {
char reserved[21];/* reserved by DOS */
char attr; /* file attributes */
int time; /* file time */
int date; /* file date */
long size; /* file size */
char name[13];/* ASCIIZ filename */
} fbuf;

Different filename templates may be searched for interchangeably by specifying a unique buffer for each _find_first and using a different buffer on each subsequent call to _find_next.

Note that the date and time values returned by this function use the same format returned by _getftime_h, _merge_time and _merge_date.

WARNING! After find_first has been called, changes to the DTA must be made using _set_dta. Failure to comply with this rule will cause subsequent _find_next calls to fail.

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   fbuf filebuf;
	   int code;
	   code = _find_first ("*.c", &filebuf, FA_NORM);
	   if (code == -1)
	   {
	      /* Handle the error */
	   } else if (code == 1)
	   {
	      /* handle no matching files */
	   } else
	   {
	      do {
	         ...
	      } while (!_find_next (&filebuf));
	      ...
	   }
	}

Inline Assembly Example
	#include <inline.h>
	{
	   fbuf filebuf;
	   char *filespec = "*.c";

	   mov si,filespec
	   pushss
	   pop es	 	/* ES = SS */
	   lea di,filebuf
	   mov ax,FA_NORM/* AX = attributes to look for */
	   find_first ();
	    ja find_first_060/* if no matching files found */
	    jb find_first_040/* if an error occurred */
	find_first_020:
	   ... 	 	/* process matching files ... */
	   find_next ();
	    je find_first_020/* if matching file was found */
	    ja find_first_060/* if no matching files found */
	find_first_040:
	   ... 	 	/* handle the error... */
	   jmp find_first_080

	find_first_060:
	   ... 	 	/* no more matching files */
	find_first_080:
	   ...
	}

Source file _FDFINDN.ASM ASM equiv FIND_NEXT
See also
_find_first

_fix_filename


Descrip
Forces the filename portion of a path string into the form of a valid filename.

Syntax
#include <filedir.h>
char *_fix_filename(char *string);

Returns
A pointer to string if the function was successful.
string a copy of string with the filename portion forced into the form of a valid filename

NULL if the filename portion of string is missing or if it could not be forced into the form of a valid filename.

Notes
This function validates the filename portion of string, forcing it into the form FFFFFFFF.XXX, where "F" represents an optional filename character and "X" represents an optional extension character. Up to eight filename characters are copied (excluding any extension). If a period is found in string, up to three extension characters are copied.

A period is copied only if an extension follows it. If the first character in string is a period or if string is a NULL string, NULL is returned.

The following are examples of path strings before and after calling _fix_path:

BEFOREAFTERCHANGE
BASETWO.DEVELOPMENTBASETWO.DEV extension truncated
ASSEMBLER.EXEASSEMBLE.EXE name truncated
LONGFILENAME.TEXTLONGFILE.TEX name and extension truncated
LONG NAME WITH NO EXTLONG NAM name truncated, no extension

Note that only the form of the filename is forced, the individual characters are not validated as legal filename characters.

C/C++ Example
	{
	   char filename[13];
	   ...
	   _fix_filename (filename);
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char filename[40] = "longfilename.longext";
	   ...
	   lea si,filename
	   fix_filename ();
	    jncfix_fname_010/* if successful */
	   ... /* filename could not be forced to the form 
	   	     of a valid filename */
	fix_fname_010:
	   ...
	}

Source file _FDFIXFN.ASM ASM equiv FIX_FILENAME
See also
_expand_path

_fix_path


Descrip
Converts a path string from internal format to DOS format.

Syntax
#include <filedir.h>
char *_fix_path(char *path);

Returns
A pointer to path.
path copy of path without an extraneous terminal backslash character ("\")

NULL if path was already in DOS format.

Notes
This function converts a string from internal Spontaneous Assembly format to DOS format by removing an extraneous terminal backslash character ("\") at the end of path (if one is found). The terminal backslash immediately following a drive specifier is not removed because it denotes the root directory.

The following are examples of path strings before and after calling _fix_path:

BEFOREAFTER CHANGE
C:\SPONTASM\C:\SPONTASM backslash removed
C:\ C:\ no change
\SPONTASM\FAST.C\SPONTASM\FAST.Cno change
\ \ no change
This function may be used to prepare path strings for display or for direct use with DOS function calls.

The terminal backslash character is appended to path-only strings in internal Spontaneous Assembly format to allow filename manipulation functions to differentiate between path-only and path-filename strings.

See the File/Directory technical notes for more information.

C/C++ Example
	{
	   char filename[13];
	   ...
	   _fix_path (filename);
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char path[50] = "c:\\util\\";
	   ...
	   lea si,path
	   fix_path ();
	    jnefix_path_010/* path already in DOS format */
	   ... 	 	/* if path was changed */
	fix_path_010:
	   ...
	}

Source file _FDFIXP.ASM ASM equiv FIX_PATH
See also
_term_path

_get_curdir


Descrip
Returns a string which describes the current working directory on a specified drive.

Syntax
#include <filedir.h>
int _get_curdir(char *buffer, int drive);

Returns
0 if the function was successful.
buffer ASCIIZ current working directory path string for drive

-1 if the function was unsuccessful.
buffer undefined
e_code error code

Notes
This function returns an ASCIIZ string which describes the current working directory on drive. Up to 68 characters may be returned in buffer, including a terminating NULL. The path returned is a complete path which includes the drive letter. drive may be any alphabetic character of either case, or 0x00 for the default drive (i.e., 'C' for drive C, 'a' for drive A, 0 for the default drive, etc.). For example, this function might return:

"D:\LANGS\SACPPLUS\"

where "D" is the drive letter provided and "\LANGS\SACPPLUS" is the current working directory on that drive. Note that this function places a terminating backslash character after the last path element. The backslash can be removed by calling the _fix_path function.

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   char buffer[68];
	   if (_get_curdir (buffer, 'C'))
	   {
	      /* Handle an error */
	   }
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[68];
	   ...
	   lea si,buffer
	   mov al,'C'	/* use C drive */
	   get_curdir ();
	    jncget_curdir_010/* if successful */
	   ... 	 	/* if an error occurred */
	get_curdir_010:
	   ...
	}

Source file _FDCURDR.ASM ASM equiv GET_CURDIR
See also
_ch_dir, _get_cwd

_get_cwd


Descrip
Returns a string which describes the current working directory on the active drive.

Syntax
#include <filedir.h>
char *_get_cwd(char *buffer);

Returns
A pointer to buffer if the function was successful.
buffer ASCIIZ current working directory path string

NULL if the function was unsuccessful.
buffer undefined
e_code error code

Notes
This function returns an ASCIIZ string which describes the current working directory on the active drive. Up to 68 characters may be returned in buffer, including the terminating NULL. The path returned is a complete path, including the drive letter. For example, this function might return:

"C:\LANGS\SACPPLUS\"

where "C" is the active drive and "LANGS\SACPPLUS" is the current working directory on that drive. Note that this function places a terminating backslash character after the last path element. It can be removed using the _fix_path function.

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   char buffer[68];
	   if (!_get_cwd (buffer))
	   {
	      /* Handle the error */
	   }
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[68];
	   ...
	   lea si,buffer
	   get_cwd ();
	    jncget_cwd_010/* if successful */
	   ... 	 	/* if an error occurred */
	get_cwd_010:
	   ...
	}

Source file _FDCWD.ASM ASM equiv GET_CWD
See also
_ch_dir, _get_curdir

_get_drive


Descrip
Gets the drive letter of the current drive.

Syntax
#include <filedir.h>
char _get_drive(void);

Returns
The uppercase drive letter of the current drive ('A' through 'Z').

Notes
This function returns the uppercase ASCII drive letter of the current drive.

C/C++ Example
	{
	   char drive;
	   drive = _get_drive(); /* drive = drive letter */
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	   ...
	   get_drive();	/* AL = drive letter */
	   ...

Source file FDGDRIVE.ASM ASM equiv GET_DRIVE
See also
_set_drive

_getmode_f


Descrip
Gets the access mode of a file, directory, or volume label.

Syntax
#include <filedir.h>
int _getmode_f(const char *filename);

Returns
The file attributes for filename if the function was successful.

-1 if an error occurred.
e_code error code

Notes
This function gets the access mode of the file, directory, or volume label identified by filename. The access mode is a combination of the following attribute flags defined in FILECNTL.H (automatically included in FILEDIR.H):

FA_NORM (0x0000) Ordinary
FA_RDONLY(0x0001) Read-only
FA_HIDDEN(0x0002) Hidden
FA_SYSTEM(0x0004) System
FA_LABEL(0x0008) Volume label
FA_SUBDIR(0x0010) Directory
FA_ARCH(0x0020) Archive

filename may not end with a terminal backslash character. If a pathname with a terminal backslash needs to be passed to this function, _fix_path should be called first.

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   if (_getmode_f ("$fd.c") != FA_NORM)
	   {
	      /* Handle file mode not matching FA_NORM */
	   } else
	   {
	      ...
	   }
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char filename[13] = "file.dat";
	   ...
	   lea si,filename
	   getmode_f ();	/* AX=file attributes */
	    jncgetmode_f_010/* if successful */
	   ... 	 	/* if an error occurred */
	getmode_f_010:
	   ...
	}

Source file _FDGETMD.ASM ASM equiv GETMODE_F
See also
_access_f, _setmode_f

_merge_drive


Descrip
Merges a drive specifier from one path string into another path string.

Syntax
#include <filedir.h>
char *_merge_drive(char far *destpath, const char *srcpath);

Returns
A pointer to destpath.
destpath copy of destpath with drive specifier from srcpath merged into the appropriate location

Notes
This function merges the drive specifier portion of srcpath into the appropriate place in destpath. If srcpath contains more than a drive specifier, only the drive specifier portion is merged. If destpath already contains a drive specifier, it is replaced with the drive specifier in srcpath. If srcpath does not contain a drive specifier, any drive specifier in destpath is removed. If destpath is a NULL string, destpath contains only the drive specifier portion of srcpath.

The following table shows the resulting destpath for various input srcpath and destpath string combinations:

Input source pathInput destination pathResulting destination path

"C:""TEST.C""C:TEST.C"
"A:\ASM\TEST.C""C:TEST.OBJ" "A:TEST.OBJ"
"\TEST\TEST.C""C:ASM\TEST.OBJ""ASM\TEST.OBJ"
"SYS:ASM\TEST.C"0 "SYS:"

C/C++ Example
	{
	   char buffer[68];
	   ...
	   _merge_drive (buffer, "c:");
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[68] = "a:\\data\\file.dat", *drive = "c";
	   ...
	   mov si,drive
	   pushss
	   pop es	 /* ES=seg buffer */
	   lea di,buffer
	   merge_drive ();/* buffer = "C:\DATA\FILE.DAT" */
	   ...
	}

Source file _FDMERGD.ASM ASM equiv MERGE_DRIVE
See also
_merge_drvpath, _merge_ext, _merge_fname, _merge_path, _split_drive

_merge_drvpath


Descrip
Merges a drive specifier and path from one path string into another.

Syntax
#include <filedir.h>
char *_merge_drvpath(char far *destpath, const char *srcpath);

Returns
A pointer to destpath.
destpath copy of destpath with drive specifier and path from srcpath merged into the appropriate location

Notes
This function merges the drive specifier and path portion of srcpath into the appropriate place in destpath. If srcpath contains more than a drive specifier and path, only the drive specifier and path portion is merged. If destpath already contains a drive specifier and/or path, it is replaced with the drive specifier and path in srcpath. If srcpath does not contain a drive specifier or path, any drive specifier or path in destpath is removed. If destpath is a NULL string, destpath returns only the drive specifier and path portion of srcpath.

The following table shows the resulting destpath for various input srcpath and destpath string combinations:

Input source pathInput destination pathResulting destination path

"C:\SPONTASM\""TEST" "C:\SPONTASM\TEST"
"C:\""ANYTHING.OBJ" "C:\ANYTHING.OBJ"
"C:\SPONTASM\""A:TEST.OBJ" "C:\SPONTASM\TEST.OBJ"
"C:\SPONTASM\""A:TEST.OBJ" "C:\TEST.OBJ"
"SPONTASM\""A:TEST.OBJ" "TEST.OBJ"
"SPONTASM\*.C""A:TEMP\TEST.OBJ" "SPONTASM\TEST.OBJ"
"SYS:TEMP\TEST.C"0 "SYS:TEMP\"

This function requires that the path portion of pathname be terminated with a backslash character ("\"). This makes it possible to differentiate between path-only and path-filename strings. The _term_path function is provided to force path-only strings to conform to this internal Spontaneous Assembly format. _fix_path is provided to convert strings from this format into DOS-compatible format. See the technical notes for more information.

C/C++ Example
	{
	   char buffer[68];
	   ...
	   _merge_drvpath (buffer, "c:\\util\\");
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[68] ="a:\\data\\file.dat", *string = "c:\\util\\";
	   ...
	   mov si,string
	   pushss
	   pop es	 	/* ES=seg buffer */
	   lea di,buffer
	   merge_drvpath ();/* buffer = "C:\UTIL\FILE.DAT" */
	   ...
	}

Source file _FDMERGV.ASM ASM equiv MERGE_DRVPATH
See also
_merge_drive, _merge_path, _split_drvpath

_merge_ext


Descrip
Merges a filename extension from one path string into another path string.

Syntax
#include <filedir.h>
char *_merge_ext(char far *destpath, const char *srcpath);

Returns
A pointer to destpath.
destpath copy of destpath with filename extension from srcpath merged into the appropriate location

Notes
This function merges the filename extension portion of srcpath into the appropriate place in destpath. If srcpath contains more than a filename extension, only the filename extension portion is merged. If destpath already containsa filename extension, it is replaced with the filename extension in srcpath. If srcpath does not contain a filename extension, any filename extension in destpath is removed. If destpath is a NULL string, destpath returns only the filename extension portion of srcpath.

The following table shows the resulting destpath for various input srcpath and destpath string combinations:

Input source pathInput destination pathResulting destination path

".C""TEST""TEST.C"
"\TEST\TEST.C""C:\WORK\*" "C:WORK\*.C"
"TEST.C" "C:TEST.OBJ" "C:TEST.C"
"TEST""C:\WORK\*.*" "C:\WORK\*"
"TEST.OBJ"0 ".OBJ"

This function requires that the path portion of pathname be terminated with a backslash character ("\"). This makes it possible to differentiate between path-only and path-filename strings. The _term_path function is provided to force path-only strings to conform to this internal format. _fix_path is provided to convert strings from this format into DOS-compatible format. See the technical notes for more information about internal and DOS path string formats.

C/C++ Example
	{
	   char buffer[68];
	   ...
	   _merge_ext (buffer, ".bak");
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[68] = "a:\\data\\file.dat", *string = ".bak";
	   ...
	   mov si,string
	   pushss
	   pop es	 /* ES=seg buffer */
	   lea di,buffer
	   merge_ext ();/* buffer = "A:\DATA\FILE.BAK" */
	   ...
	}

Source file _FDMERGE.ASM ASM equiv MERGE_EXT
See also
_merge_drive, _merge_fname, _merge_fname, _merge_path, _split_ext

_merge_fname


Descrip
Merges a filename from one path string into another path string.

Syntax
#include <filedir.h>
char *_merge_fname(char far *destpath, const char *srcpath);

Returns
A pointer to destpath.
destpath copy of destpath with filename from srcpath merged into the appropriate location

Notes
This function merges the filename portion of srcpath into the appropriate place in destpath. If srcpath contains more than a filename, only the filename portion is merged. If destpath already contains a filename, it is replaced with the filename in srcpath. If srcpath does not contain a filename, any filename in destpath is removed. If destpath is a NULL string, destpath returns only the filename portion of srcpath.

Note that this function merges only the filename-not the extension. The extension may be merged using _merge_ext, or the filename and extension may be merged as a unit using _merge_fnamext.

The following table shows the resulting destpath for various input srcpath and destpath string combinations:

Input source pathInput destination pathResulting destination path

"TEST.C" "PROGRAM.EXE" "TEST.EXE"
"C:\TEST\TEST.C""C:\FAST\*.*" "C:FAST\TEST.*"
"A:\KEVIN""M:CRENSHAW\" "M:CRENSHAW\KEVIN"
0 "ANYTHING.CPP" ".CPP"
"TEST.OBJ"0 "TEST"

This function requires that the path portion of pathname be terminated with a backslash character ("\"). This makes it possible to differentiate between path-only and path-filename strings. The _term_path function is provided to force path-only strings to conform to this internal format. _fix_path is provided to convert strings from this format into DOS-compatible format. See the technical notes for more information about internal and DOS path string formats.

C/C++ Example
	{
	   char buffer[68];
	   ...
	   _merge_fname (buffer, "tempfile");
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[68] = "a:\\data\\file.dat", *string = "tempfile";
	   ...
	   mov si,string
	   pushss
	   pop es	 /* ES=seg buffer */
	   lea di,buffer
	   merge_fname ();/* buffer = "A:\DATA\TEMPFILE.DAT" */
	   ...
	}

Source file _FDMERGN.ASM ASM equiv MERGE_FNAME
See also
_merge_drive, _merge_ext, _merge_fname, _merge_path, _split_fname

_merge_fnamext


Descrip
Merges a filename and extension from one path string into another path string.

Syntax
#include <filedir.h>
char *_merge_fnamext(char far *destpath, const char *srcpath);

Returns
A pointer to destpath.
destpath copy of destpath with filename and extension from srcpath merged into the appropriate location

Notes
This function merges the filename and extension portion of srcpath into the appropriate place in destpath. If srcpath contains more than a filename and extension, only the filename and extension portion is merged. If destpath already contains a filename and/or extension, it is replaced with the filename and extension in srcpath. If srcpath does not contain a filename or extension, any filename or extension in destpath is removed. If destpath is a NULL string, destpath returns only the filename and extension portion of srcpath.

The following table shows the resulting destpath for various input srcpath and destpath string combinations:
Input source pathInput destination pathResulting destination path

"TEST.CPP""PROGRAM.EXE" "TEST.CPP"
"C:\TEST\TEST.C""C:\WORK\*.*" "C:WORK\TEST.C"
"TEST\ANYTHING.C""C:\WORK\" "C:WORK\ANYTHING.C"
"A:\TEST.OBJ"0 "TEST.OBJ"
0 "A:ANYTHING.C" "A:"

This function requires that the path portion of pathname be terminated with a backslash character ("\"). This makes it possible to differentiate between path-only and path-filename strings. The _term_path function is provided to force path-only strings to conform to this internal format. _fix_path is provided to convert strings from this format into DOS-compatible format. See the technical notes for more information about internal and DOS path string formats.

C/C++ Example
	{
	   char buffer[68];
	   ...
	   _merge_fnamext (buffer, "tempfile.tmp");
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[68] ="a:\\data\\file.dat", *string = "tfile.tmp";
	   ...
	   mov si,string
	   pushss
	   pop es	 	/* ES=seg buffer */
	   lea di,buffer
	   merge_fnamext ();/* buffer = "A:\DATA\TFILE.TMP" */
	   ...
	}

Source file _FDMERGX.ASM ASM equiv MERGE_FNAMEXT
See also
_merge_ext, _merge_fname, _split_fname

_merge_path


Descrip
Merges a path from one path string into another path string.

Syntax
#include <filedir.h>
char *_merge_path(char far *destpath, const char *srcpath);

Returns
A pointer to destpath.
destpath copy of destpath with path from srcpath merged into the appropriate location

Notes
This function merges the path portion of srcpath into the appropriate place in destpath. If srcpath contains more than a path, only the path portion is merged. If destpath already contains a path, it is replaced with the path in srcpath. If srcpath does not contain a path, any path in destpath is removed. If destpath is a NULL string, destpath returns only the path portion of srcpath.

Note that this function merges only the path-not the drive specifier. The drive specifier may be merged using _merge_drive, or the drive specifier and path may be merged as a unit using _merge_drvpath.

The following table shows the resulting destpath for a few input srcpath and destpath strings:

Input source pathInput destination pathResulting destination path

"C:\SPONTASM\""TEST" "\SPONTASM\TEST"
"C:\""ANYTHING.OBJ" "\ANYTHING.OBJ"
"C:\SPONTASM""A:TEST.OBJ" "A:\TEST.OBJ"
"SPONTASM\*.CPP""A:WORK\TEST.OBJ" "A:SPONTASM\TEST.OBJ"
"C:WORK\TEST.CPP"0 "WORK\"

This function requires that the path portion of pathname be terminated with a backslash character ("\"). This makes it possible to differentiate between path-only and path-filename strings. The _term_path function is provided to force path-only strings to conform to this internal format, and _fix_path is provided to convert strings from this format into DOS-compatible format. See the technical notes for more information about internal and DOS path string formats.

C/C++ Example
	{
	   char buffer[68];
	   ...
	   _merge_path (buffer, "\\util\\");
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[68] = "a:\\data\\file.dat", *string = "\\util\\";
	   ...
	   mov si,string
	   pushss
	   pop es	 	/* ES=seg buffer */
	   lea di,buffer
	   merge_path ();	/* buffer = "A:\UTIL\FILE.DAT" */
	   ...
	}

Source file _FDMERGP.ASM ASM equiv MERGE_PATH
See also
_merge_drive, _merge_drvpath, _merge_ext, _merge_fname, _split_path

_mk_dir


Descrip
Creates a new directory.

Syntax
#include <filedir.h>
int _mk_dir(const char *path);

Returns
0 if the directory was successfully created.

-1 if the directory could not be created.
e_code error code

Notes
This function creates a new directory on any valid drive. If path includes a drive specifier, the directory is created on that drive. If no drive is specified, the directory is created on the active drive. 0 is returned if the function was successful. -1 is returned and the corresponding error code is placed in e_code if the directory could not be created.

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   char pathname[50] = "temp????";
	   ...
	   if (_mk_temp (pathname) || _mk_dir (pathname))
	   {
	      /* Handle the error */
	   } else
	   {
	      if (_rm_dir (pathname))
	      {
	         /* Handle the error */
	      } else
	      {
	         ...
	      }
	   }
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char pathname[50] = "mydir";
	   ...
	   lea si,pathname
	   mk_dir ();	/* make "MYDIR" subdirectory */
	    jc mk_dir_010/*   if an error occurred */
	   ... 	 	/*   if successful */
	   rm_dir ();	/* remove "MYDIR" subdirectory */
	    jc mk_dir_010/*   if an error occurred */
	   ... 	 	/*   if successful */
	   jmp short mk_dir_020

	mk_dir_010:
	   ... 	 	/* handle the error */
	mk_dir_020:
	   ...
	}

Source file _FDMKDIR.ASM ASM equiv MK_DIR
See also
_ch_dir, _rm_dir

_mk_temp


Descrip
Generates a unique filename from a template.

Syntax
#include <filedir.h>
int _mk_temp(char *fname);

Returns
0 if the function was successful.
name temporary ASCIIZ filename

1 if a unique filename could not be generated from fname.
name undefined

-1 if an error occurred.
name undefined
e_code error code

Notes
This function generates a unique filename for use in the specified directory using a template. A drive and path may be specified in fname. If no drive or path is specified, the active drive and current working directory are used. The temporary filename is formed from the filename portion of fname, which must be a template consisting of valid filename characters and '?' wildcard characters. Each occurrence of a '?' character in the filename is replaced with a '0' through '9' character until an available filename is found or until all possibilities have been tried without success. 0 is returned if the temporary filename was successfully created in fname. 1 is returned if no unique filenames could be constructed from the template in fname. -1 is returned if an error occurred.

WARNING! If the '*' character is encountered in name, 1 is returned.

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   char pathname[50] = "temp????";
	   ...
	   if (_mk_temp (pathname) || _mk_dir (pathname))
	   {
	      /* Handle the error */
	   } else
	   {
	      if (_rm_dir (pathname))
	      {
	         /* Handle the error */
	      } else
	      {
	         ...
	      }
	   }
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[13] = "temp????";
	   ...
	   lea si,buffer
	   mk_temp ();	/* generate a temp filename */
	    jc mk_temp_010/*   if an error occurred */
	   mov ax,FA_NORM/* setup to create as "normal" */
	   create_h ();	/* create tempfile, BX = handle */
	    jc mk_temp_010/*   if an error occurred */
	   ... 	 	/*   if successful */
	   close_h ();	/* close file w/handle in BX */
	    jc mk_temp_010/*   if an error occurred */
	   remove_h ();	/* remove temp file */
	    jc mk_temp_010/*   if an error occurred */
	   ... 	 	/* more stuff... */
	mk_temp_010:
	   ... 	 	/* handle the error */
	}

Source file _FDMKTMP.ASM ASM equiv MK_TEMP
See also
_create_h

_remove_f


Descrip
Deletes a file.

Syntax
#include <filedir.h>
int _remove_f(const char *pathname);

Returns
0 if the file was successfully deleted.

-1 if an error occurred.
e_code error code

Notes
This function deletes the file indicated by pathname. If pathname does not include a drive specifier or path, this function attempts to delete the file from the current working directory on the active drive.

This function cannot be used to remove a subdirectory. The _rm_dir function is provided for this purpose.

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   char pathname[50];
	   ...
	   if (_remove_f (pathname))
	   {
	      /* Handle the error */
	   } else
	   {
	      ...
	   }
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char pathname[50] = "file.dat";
	   ...
	   lea si,pathname
	   remove_f ();
	    jc remove_f_010/* if an error occurred */
	   ... 	 	/* if successful */
	   jmp short remove_f_020

	remove_f_010:
	   ... 	 	/* handle the error */
	remove_f_020:
	   ...
	}

Source file _FDREMOV.ASM ASM equiv REMOVE_F
See also
_create_h, _rm_dir

_rename_f


Descrip
Renames a file or directory.

Syntax
#include <filedir.h>
int _rename_f(const char *oldname, const char far *newname);

Returns
0 if oldname was successfully renamed to newname.

-1 if the function was unsuccessful.
e_code error code

Notes
This function renames oldname to newname. oldname can be a file (or directory if DOS 3.0 or above is being used) and can include a drive specifier and a path. A file can be moved using _rename_f by providing a path in newname that is different than the path specified in oldname. However, due to DOS limitations, the drive specifiers in the path strings must be the same or -1 is returned.

Directories can only be renamed under DOS 3.0 and above.

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   char pathname1[50], pathname2[50];
	   ...
	   if (_rename_f (pathname1, pathname2))
	   {
	      /* Handle the error */
	   } else
	   {
	      ...
	   }
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char pathname1[50] = "file.dat", pathname2[50] = "temp.fil";
	   ...
	   lea si,pathname1
	   pushss
	   pop es	 	/* ES=SS */
	   lea di,pathname2
	   rename_f ();
	    jc rename_f_010/* if an error occurred */
	   ... 	 	/* if successful */
	   jmp short rename_f_020

	rename_f_010:
	   ... 	 	/* handle the error */
	rename_f_020:
	   ...
	}

Source file _FDRENAM.ASM ASM equiv RENAME_F

_rm_dir


Descrip
Removes an empty directory.

Syntax
#include <filedir.h>
int _rm_dir(const char *name);

Returns
0 if the directory was successfully deleted.

-1 if the directory could not be deleted.
e_code error code

Notes
This function removes the directory specified by name if it is empty. Directories can be deleted from any valid drive. name may include a trailing backslash character ("\"). -1 is returned if the directory is not empty or if it is currently in use.

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   char pathname[50] = "temp????";
	   int cond;
	   ...
	   if (_mk_temp (pathname, &cond) || _mk_dir (pathname))
	   {
	      /* Handle the error */
	   } else
	   {
	      if (_rm_dir (pathname))
	      {
	         /* Handle the error */
	      } else
	      {
	         ...
	      }
	   }
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char pathname[50] = "mydir";
	   ...
	   lea si,pathname
	   mk_dir ();	/* make "MYDIR" subdirectory */
	    jc mk_dir_010/*   if an error occurred */
	   ... 	 	/*   if successful */
	   rm_dir ();	/* remove "MYDIR" subdirectory */
	    jc mk_dir_010/*   if an error occurred */
	   ... 	 	/*   if successful */
	   jmp short mk_dir_020

	mk_dir_010:
	   ... 	 	/* handle the error */
	mk_dir_020:
	   ...
	}

Source file _FDRMDIR.ASM ASM equiv RM_DIR_
See also
ch_dir, _mk_dir

_search_path


Descrip
Searches for a file.

Syntax
#include <filedir.h>
char *_search_path(char *namebuf, const char far *pathstr);

Returns
A pointer to namebuf if a matching file was found.
namebuf the complete path followed by the specified ASCIIZ filename template

NULL if an error occurred or no match was found.
e_code error code

Notes
This function searches for a file which matches the filename template in namebuf. The current working directory is searched first, followed by each path specified in pathstr. If an invalid path is specified in pathstr, it is ignored. Searching continues until a matching file is found or until all the paths have been searched unsuccessfully. If a matching file is found, a pointer to namebuf is returned, and the filename template in namebuf is prefixed with the path where the matching file was found. NULL is returned if no matching file is found or if an error occurred.

pathstr must be in the same form as the PATH environment string (each pathname must be terminated by a semicolon and the entire list must be terminated with a NULL character), as follows:

"C:\;C:\DOS;C:\LANGS\SPONTASM;D:\;"

This string should contain no whitespace characters. The semicolon after the last path in the string is optional. The _get_env function may be used to obtain a pointer to the PATH environment variable or any other environment variable which contains a path string.

The filename template in namebuf may include wildcard characters, but it must not include a drive specifier or path.

WARNING! The resulting path and filename string in namebuf may contain up to 80 characters including the terminal NULL. If namebuf is not large enough, data following namebuf may be overwritten.

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code are defined in Appendix A.

C/C++ Example
	{
	   char buffer[80];
	   ...
	   if (_search_path (buffer, "c:\\;c:\\work\\stub;") == NULL)
	   {
	      /* Handle the error */
	   } else
	   {
	      ...
	   }
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer[50] = "file.dat", *path="c:\\;c:\\util;c:\\bin;";
	   ...
	   pushss
	   pop es	 	/* ES=DS (path pntr on stack) */
	   mov di,path	    /* DI = offset of buffer */
	   lea si,buffer/* SI = offset of buffer */
	   search_path ();    /* specified pathname found? */
	    je srch_path_010/*   y: process pathname */
	    ja srch_path_020/*   n: path not found */
	   ... 	 	/*   if an error occurred */
	   jmp short srch_path_030

	srch_path_010:
	   ... 	 	/* process pathname */
	   jmp short srch_path_030
	srch_path_020:
	   ... 	 	/* path not found */
	srch_path_030:
	   ...
	}

Source file _FDSRCHP.ASM ASM equiv SEARCH_PATH
See also
_get_env

_set_drive


Descrip
Selects a new disk drive.

Syntax
#include <filedir.h>
int _set_drive(int drive);

Returns
0 if drive was selected as the new default disk drive.

-1 if drive is invalid.

Notes
This function selects drive to be the new default disk drive. drive must be a valid drive letter ('A' through 'Z'). -1 is returned if drive represents an invalid drive.

C/C++ Example
	   if (_set_drive ('D'))
	   {
	      /* Handle the error */
	   } else
	   {
	      ...
	   }

Inline Assembly Example
	#include <inline.h>
	   ...
	   mov al,'C'	/* AL=drive letter to use */
	   set_drive ();
	    jncset_drive_010/* if successful */
	   ... 	 	/* if an error occurred */
	set_drive_010:
	   ...

Source file _FDSDRIV.ASM ASM equiv SET_DRIVE
See also
_get_drive

_setmode_f


Descrip
Changes the access mode of a file.

Syntax
#include <filedir.h>
int _setmode_f(const char *filename, int attr);

Returns
0 if the function was successful.
-1 if an error occurred.
e_code error code

Notes
This function changes the access mode or file attributes of filename to attr. 0 is returned if the function was successful. -1 is returned and an error code is placed in e_code if an error occurred.

attr is created by bitwise ORing together the following symbolic constants defined in FILECNTL.H (automatically included from FILEDIR.H):

FA_NORM(0x0000) Ordinary
FA_RDONLY(0x0001) Read-only
FA_HIDDEN(0x0002) Hidden
FA_SYSTEM(0x0004) System
FA_ARCH(0x0020) Archive

e_code may be obtained using the _get_ecode function. Symbolic constants for e_code values are defined in Appendix A.

C/C++ Example
	{
	   char filename[13];
	   ...
	   if (_setmode_f (filename, FA_NORM))
	   {
	      /* Handle the error */
	   } else
	   {
	      ...
	   }
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char filename[13] = "file.dat";
	   ...
	   lea si,filename
	   mov ax,FA_NORM/* AX=file mode attributes */
	   setmode_f ();
	    jncsetmode_f_010/* if successful */
	   ... 	 	/* if an error occurred */
	setmode_f_010:
	   ...
	   }

Source file _FDSETMD.ASM ASM equiv SETMODE_F
See also
_getmode_f

_split_drive


Descrip
Returns a drive specifier string from a pathname.

Syntax
#include <filedir.h>
char *_split_drive(char far *buffer, const char *pathname);

Returns
A pointer to buffer.
buffer ASCIIZ drive specifier string (NULL string if none)

Notes
This function copies the drive specifier portion of pathname into buffer and appends a terminating NULL. If pathname does not contain a drive specifier, a NULL string is placed in buffer. For example, if pathname is "C:\SPONTASM\FAST.C" then "C:" is copied into buffer.

C/C++ Example
	{
	   char buffer1[50], buffer2[50];
	   ...
	   _split_drive (buffer1, buffer2);
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer1[50], buffer2[50] = "a:\\data\\file.dat";
	   ...
	   lea si,buffer2
	   pushss
	   pop es	 	/* ES=SS (pntr on stack) */
	   lea di,buffer1/* DI = offset buffer1 */
	   split_drive ();    /* buffer1 = "C:" */
	   ...
	}

Source file _FDSPLTD.ASM ASM equiv SPLIT_DRIVE
See also
_merge_drive, _split_drvpath, _split_ext, _split_fname, _split_path

_split_drvpath


Descrip
Returns a drive specifier and path string from a pathname.

Syntax
#include <filedir.h>
char *_split_drvpath(char far *buffer, const char *pathname);

Returns
A pointer to buffer.
buffer ASCIIZ drive specifier and path string (NULL string if none)

Notes
This function copies the drive specifier and path portion of pathname into buffer and appends a terminating NULL. If pathname does not contain a drive specifier or path, a NULL string is placed in buffer. For example, if pathname is "C:\SPONTASM\FAST.C" then "C:\SPONTASM\" is copied into buffer.

This function requires that the path portion of pathname be terminated with a backslash character ("\"). This makes it possible to differentiate betweenpath-only and path-filename strings. The _term_path function is provided to force path-only strings to conform to this internal format. _fix_path is provided to convert strings from this format into DOS-compatible format.

See the technical notes for more information about internal and DOS path string formats.

C/C++ Example
	{
	   char buffer1[50], buffer2[50];
	   ...
	   _split_drvpath (buffer1, buffer2);
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer1[50], buffer2[50] = "a:\\data\\file.dat";
	   ...
	   lea si,buffer2
	   pushss
	   pop es	 	/* ES=SS */
	   lea di,buffer1
	   split_drvpath ();/* buffer1 = "C:\DATA\" */
	   ...
	}

Source file _FDSPLTV.ASM ASM equiv SPLIT_DRVPATH
See also
_merge_drvpath, _split_drive, _split_path

_split_ext


Descrip
Returns a file extension string from a pathname.

Syntax
#include <filedir.h>
char *_split_ext(char far *buffer, const char *pathname);

Returns
A pointer to buffer.
buffer ASCIIZ file extension string (NULL string if none)

Notes
This function copies the file extension portion of pathname into buffer and appends a terminating NULL. If pathname does not contain a file extension, a NULL string is placed in buffer. For example, if pathname is "C:\SPONTASM\SMALL.CPP" then ".CPP" is copied into buffer.

This function requires that the path portion of pathname be terminated with a backslash character ("\"). This makes it possible to differentiate between path-only and path-filename strings. The _term_path function is provided to force path-only strings to conform to this internal format. _fix_path is provided to convert strings from this format into DOS-compatible format.

See the technical notes for more information about internal and DOS path string formats.

C/C++ Example
	{
	   char buffer1[50], buffer2[50];
	   ...
	   _split_ext (buffer1, buffer2);
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer1[50], buffer2[50] = "a:\\data\\file.dat";
	...
	lea si,buffer2
	pushss
	pop es 	 /* ES=SS */
	lea di,buffer1
	split_ext ();	 /* buffer1 = ".DAT" */
	...
	}

Source file _FDSPLTE.ASM ASM equiv SPLIT_EXT
See also
_merge_ext, _split_drive, _split_fname, _split_fname, _split_path

_split_fname


Descrip
Returns a filename string from a pathname.

Syntax
#include <filedir.h>
char *_split_fname(char far *buffer, const char *pathname);

Returns
A pointer to buffer.
buffer ASCIIZ filename string (NULL string if none)

Notes
This function copies the filename portion of pathname into buffer and appends a terminating NULL. If pathname does not contain a filename, a NULL string is placed in buffer. For example, if pathname is "C:\SPONTASM\FAST.C" then "FAST" is copied into buffer.

This function requires that the path portion of pathname be terminated with a backslash character ("\"). This makes it possible to differentiate between path-only and path-filename strings. The _term_path function is provided to force path-only strings to conform to this internal format. _fix_path is provided to convert strings from this format into DOS-compatible format.

See the technical notes for more information about internal and DOS path string formats.

C/C++ Example
	{
	   char buffer1[50], buffer2[50];
	   ...
	   _split_fname (buffer1, buffer2);
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer1[50], buffer2[50] = "a:\\data\\file.dat";
	...
	lea si,buffer2
	pushss
	pop es 	 /* ES=SS */
	lea di,buffer1
	split_fname ();	/* buffer1 = "FILE" */
	...
	}

Source file _FDSPLTN.ASM ASM equiv SPLIT_FNAME
See also
_merge_fname, _split_drive, _split_ext, _split_fname, _split_path

_split_fnamext


Descrip
Returns a filename and extension string from a pathname.

Syntax
#include <filedir.h>
char *_split_fnamext(char far *buffer, const char *pathname);

Returns
A pointer to buffer.
buffer ASCIIZ filename and extension string (NULL string if none)

Notes
This function copies the filename and extension portion of pathname into buffer and appends a terminating NULL. If string does not contain a filename and extension, a NULL string is placed in buffer. For example, if pathname is "C:\SPONTASM\SMALL.C" then "SMALL.C" is copied into buffer.

This function requires that the path portion of pathname be terminated with a backslash character ("\"). This makes it possible to differentiate between path-only and path-filename strings. The _term_path function is provided to force path-only strings to conform to this internal format. _fix_path is provided to convert strings from this format into DOS-compatible format.

See the technical notes for more information about internal and DOS path string formats.

C/C++ Example
	{
	   char buffer1[50], buffer2[50];
	   ...
	   _split_fnamext (buffer1, buffer2);
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer1[50], buffer2[50] = "a:\\data\\file.dat";
	   ...
	   lea si,buffer2
	   pushss
	   pop es	 	/* ES=SS */
	lea di,buffer1
	split_fnamext ();/* buffer1 = "FILE.DAT" */
	...
	}

Source file _FDSPLTX.ASM ASM equiv SPLIT_FNAMEXT
See also
_merge_fname, _split_ext, _split_fname

_split_path


Descrip
Returns a path string from a pathname.

Syntax
#include <filedir.h>
char *_split_path(char far *buffer, const char *pathname);

Returns
A pointer to buffer.
buffer ASCIIZ path string (NULL string if none)

Notes
This function copies the path portion of pathname into buffer and appends a terminating NULL. If pathname does not contain a path, a NULL string is placed in buffer. For example, if pathname is "C:\SPONTASM\SMALL.C" then "\SPONTASM\" is copied into buffer.

This function requires that the path portion of pathname be terminated with a backslash character ("\"). This makes it possible to differentiate between path-only and path-filename strings. The _term_path function is provided to force path-only strings to conform to this internal format. _fix_path is provided to convert strings from this format into DOS-compatible format.

See the technical notes for more information about internal and DOS path string formats.

C/C++ Example
	{
	   char buffer1[50], buffer2[50];
	   ...
	   _split_path (buffer1, buffer2);
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char buffer1[50], buffer2[50] = "a:\\data\\file.dat";
	   ...
	   lea si,buffer2
	   pushss
	   pop es	 	/* ES=SS */
	   lea di,buffer1
	   split_path ();	/* buffer1 = "\DATA\" */
	   ...
	}

Source file _FDSPLTP.ASM ASM equiv SPLIT_PATH
See also
_merge_path, _split_drive, _split_drvpath, _split_ext, _split_fname

_term_path


Descrip
Converts a path string from DOS format to internal format.

Syntax
#include <filedir.h>
char *_term_path(char *path);

Returns
A pointer to path.
path a copy of path with a terminal backslash character ("\") appended

Notes
This function converts a path-only string into Spontaneous Assembly internal format by appending a backslash character ("\") if one is not already present and if at least one subdirectory is present in path.

The following are examples of path strings before and after calling TERM_PATH:

BEFORE AFTER CHANGE
C:\SPONTASMC:\SPONTASM\ append backslash
C:SPONTASMC:SPONTASM\ append backslash
C:\ C:\ no change
\SPONTASM\\SPONTASM\ no change
C: C: no change

A terminal backslash character is appended to path-only strings in Spontaneous Assembly internal format to allow filename manipulation functions to differentiate between path-only and path-filename strings. Terminal backslashes must be removed before using path strings with DOS function calls. _fix_path is provided for this purpose.

C/C++ Example
	{
	   char pathname[50];
	   ...
	   _term_path (pathname);
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char pathname[50] = "\\util";
	   ...
	   lea si,pathname
	   term_path ();/* pathname = "\UTIL\" */
	   ...
	}

Source file _FDTERMP.ASM ASM equiv TERM_PATH
See also
_fix_path