home *** CD-ROM | disk | FTP | other *** search
- /*
- pcdir.c
-
- % DOS-specific file and directory handling functions.
-
- 6/27/90 by Mike and Ted.
-
- OWL-PC 1.2
- Copyright (c) 1990 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 10/15/90 jdc preened Descend code
- 10/18/90 mla added ..\ case to pcdir_Ascend
- 10/18/90 ted/jmd changed int86ds to int86 for GETDTA case
- 10/20/90 mla rewrote pcdir_ascend
- 10/21/90 mla added colon sensitivty to pcdir_Ascend
- 10/23/90 mla added NULL path, name protection to Split
- 10/24/90 mla added _IsFullSpec, allowed common 1st & 4th args in Join
- 10/28/90 mla preened
- 10/31/90 jdc fixed mallocs
- 12/05/90 ted defined OAK_DOS to avoid confusion w/ OS/2 in oakdir.h.
- 12/15/90 mla fixed return value in pcdir_StripCase
- 12/15/90 mla rewrote pcdir_GetCurrDir to return absolute path and
- drive in lower case, fixed return value too.
- 12/15/90 mla made pcdir_Ascend drive letter sensative.
- */
- #include "pcpriv.h"
-
- #include <ctype.h>
- #include <time.h>
-
- #include "oaktime.h"
-
- #ifndef OAK_DOS
- # define OAK_DOS
- #endif
- #include "oakdir.h"
- /* -------------------------------------------------------------------------- */
- /* Mask to ignore bit not used in the masks for odir_Open */
- #define OFILE_MASK 0x07
-
- /* DOS path separator character */
- #define OFILE_SEPCHAR '\\'
-
- /* DOS file system attribute masks */
- #define DOS_READONLY 0x01
- #define DOS_HIDDEN 0x02
- #define DOS_LABEL 0x08
- #define DOS_SDIR 0x10
- #define DOS_ALL 0x3f
-
- /* DOS flags resister carry bit mask */
- #define CARRYMASK 0x0001
-
- /* DOS file type filter function */
- OSTATIC boolean typemask(byte type, byte mask);
-
- /* DOS dependent directory info here (what odir_type points to) */
- typedef struct _dta {
- char reserved[21]; /* reserved for use by DOS */
- byte attrib; /* files attributes */
- unsigned short time; /* time of last write to file */
- unsigned short date; /* date of last write to file */
- unsigned long size; /* size of file in bytes */
- char name[13]; /* name of file */
- } dta_struct;
-
- typedef struct _pcdir {
- boolean first;
- byte file_type;
- char path[OFILE_PATHLEN];
- dta_struct file_dta;
- } pcdir_struct;
- /* -------------------------------------------------------------------------- */
-
- odir_type pcdir_Open(char *user_spec, byte file_type)
- /*
- This routine opens an oakland directory stream and returns a handle to it.
- The handle is then used in calls to odir_Read, and odir_Close.
- If the stream cannot be opened for any reason, or if it is empty,
- NULL is returned.
-
-
- The first parameter is a string which should specify a path to the
- directory and a mask to use to filter the filenames in the directory.
- If the first parameter is specifies only a path (no file mask), the
- indicated directory is used and the filenames are not filtered. If the
- first parameter is NULL or "", the current directory is used and
- the filenames are not filtered.
-
- The second parameter is a mask which is used to filter the directory
- entries by type. Defined masks are:
- OFILE_ALL - does no type filtering. Everything available from
- the opering system.
- OFILE_DIRS - Returns subdirectories within the specified directory.
- OFILE_FILES - Returns files in the specified directory.
- The masks can be used alone or in combination with each other by bitwise
- or'ing the masks together. If OFILE_ALL is used in conjuction with other
- masks, it has the same effect as if used alone.
- */
- {
- pcdir_struct *odirp;
- dta_struct *olddta;
- OREGS regs;
- char *internal_spec, dummy_name[OFILE_NAMELEN];
-
- if ((odirp = (pcdir_struct *) omalloc(ID_ODIR, sizeof(pcdir_struct))) == NULL) {
- return (NULL);
- }
- regs.h.ah = DOS_GETDTA; /* save dta */
- oakint86(DOS_INT, ®s);
- regs.x.dx = regs.x.bx;
- olddta = (dta_struct *) regs.a.esdx;
-
- regs.h.ah = DOS_SETDTA;
- regs.a.esdx = &odirp->file_dta;
- regs.x.ds = regs.x.es;
- oakint86ds(DOS_INT, ®s, 0);
-
- /* adjust path to include a wildcard for filenames */
- if (user_spec == NULL || *user_spec == '\0') {
- if ((internal_spec = (char *) omalloc(OA_NOTAG, strlen(OFILE_WILDCARD) + 1)) == NULL) {
- ofree(ID_ODIR, odirp);
- odirp = NULL;
- return(NULL);
- }
- strcpy(internal_spec, OFILE_WILDCARD);
- }
- else {
- if (user_spec[strlen(user_spec) - 1] == OFILE_SEPCHAR
- || user_spec[strlen(user_spec) - 1] == ':') {
- /* user_spec is just a path (no file mask) */
- if ((internal_spec = (char *) omalloc(OA_NOTAG, strlen(user_spec)
- + strlen(OFILE_WILDCARD) + 1)) == NULL) {
- ofree(ID_ODIR, odirp);
- odirp = NULL;
- return(NULL);
- }
- strcpy(internal_spec, user_spec);
- strcat(internal_spec, OFILE_WILDCARD);
- }
- else {
- if ((internal_spec = (char *) omalloc(OA_NOTAG, strlen(user_spec) + 1))
- == NULL) {
- ofree(ID_ODIR, odirp);
- odirp = NULL;
- return(NULL);
- }
- strcpy(internal_spec, user_spec);
- }
- }
-
- regs.h.ah = DOS_FINDFIRST;
- regs.a.esdx = internal_spec; /* ds:dx -> spec */
- regs.x.ds = regs.x.es;
- regs.x.cx = DOS_ALL; /* gets all files, we'll filter manually */
-
- /* If no matches */
- if (oakint86ds(DOS_INT, ®s, strlen(internal_spec)) & CARRYMASK) {
- ofree(ID_ODIR, odirp);
- odirp = NULL;
- }
-
- ofree(OA_NOTAG, internal_spec);
-
- regs.h.ah = DOS_SETDTA; /* restore dta */
- regs.a.esdx = olddta;
- regs.x.ds = regs.x.es;
- oakint86ds(DOS_INT, ®s, 0);
-
- if (odirp == NULL) {
-
- return(NULL);
- }
-
- odirp->first = TRUE;
-
- /* pass requested attrs down so read can filter */
- odirp->file_type = file_type;
-
- /* pass the path down so it can be appended to the filenames when output */
- pcdir_Split(user_spec, odirp->path, sizeof(odirp->path), dummy_name, sizeof(dummy_name));
-
- return((odir_type) odirp);
- }
- /* -------------------------------------------------------------------------- */
-
- boolean pcdir_Read(odir_type odirpa, ofile_struct *file_info)
- /*
- This routine reads the next entry from an oakland directory stream.
- If an entry is found to return, pcdir_Read returns TRUE. If there
- are no more entries in the stream, it returns FALSE.
-
- The first parameter is the directory stream from which to fetch an entry.
-
- The second parameter is a pointer to an ofile_struct where the information
- about the entry will be stored. Once the information has been put into
- the ofile_struct, the following macros may be used to access it:
- ofile_GetType() - returns the type of the file: OFILE_ALL if it was
- specified in the call to odir_Open for this stream,
- OFILE_FILES for files, and OFILE_DIRS for dirs.
- ofile_GetTime() - returns an ansi struct tm with the date and time
- the file was last modified.
- ofile_GetSize() - returns the size of the file in bytes.
- ofile_GetSpec() - returns the spec for the file including a path
- starting where the spec given to odir_Open started.
- They each take a single parameter: the ofile_struct of the entry of
- interest. (Note: NOT a pointer to the ofile_struct)
- */
- {
- pcdir_struct *odirp;
- dta_struct *olddta;
- boolean foundone;
- OREGS regs;
-
- odirp = (pcdir_struct *) odirpa;
-
- if (odirp == NULL) {
- return(FALSE);
- }
-
- regs.h.ah = DOS_GETDTA; /* save dta */
- oakint86(DOS_INT, ®s);
- regs.x.dx = regs.x.bx;
- olddta = (dta_struct *) regs.a.esdx;
-
- regs.h.ah = DOS_SETDTA;
- regs.a.esdx = &odirp->file_dta;
- regs.x.ds = regs.x.es;
- oakint86ds(DOS_INT, ®s, 0);
-
- if (odirp->first) { /* If first use the first dta full */
- odirp->first = FALSE;
- foundone = TRUE;
- }
- else { /* Otherwise get a new dta full */
- regs.h.ah = DOS_FINDNEXT;
-
- if (oakint86ds(DOS_INT, ®s, 0) & CARRYMASK) { /* If no more matches */
- foundone = FALSE;
- }
- else {
- foundone = TRUE;
- }
- }
-
- /* if this file doesn't have at least one requested attribute,
- discard it and get another */
- while (!typemask(odirp->file_dta.attrib, odirp->file_type)) {
-
- regs.h.ah = DOS_FINDNEXT;
-
- if (oakint86ds(DOS_INT, ®s, 0) & CARRYMASK) { /* If no more matches */
- foundone = FALSE;
- break;
- }
- }
-
- regs.h.ah = DOS_SETDTA; /* restore dta */
- regs.a.esdx = olddta;
- regs.x.ds = regs.x.es;
- oakint86ds(DOS_INT, ®s, 0);
-
- if (foundone) {
- /* Copy from DOS dta structure into OS-independent file_info structure */
-
- /* files attributes */
- if (odirp->file_type & OFILE_ALL) {
- file_info->type = OFILE_ALL;
- }
- else {
- switch (OFILE_MASK & odirp->file_type) {
- case OFILE_DIRS:
- case OFILE_FILES:
- file_info->type = odirp->file_type;
- break;
- case OFILE_DIRS | OFILE_FILES:
- if (odirp->file_dta.attrib & DOS_SDIR) {
- file_info->type = OFILE_DIRS;
- }
- else {
- file_info->type = OFILE_FILES;
- }
- break;
- }
- }
-
- /* time of last write */
- file_info->time.tm_hour = (odirp->file_dta.time) >> 11;
- file_info->time.tm_min = (odirp->file_dta.time & 0x07e0) >> 5;
- file_info->time.tm_sec = (odirp->file_dta.time & 0x001f) << 1;
-
- /* date of last write */
- file_info->time.tm_year = (odirp->file_dta.date >> 9) + 1980;
- file_info->time.tm_mon = (odirp->file_dta.date & 0x01e0) >> 5;
- file_info->time.tm_mday = odirp->file_dta.date & 0x001f;
-
- /* calculate weekday, yearday, and dst values */
- tm_Adjust(&file_info->time);
-
- file_info->size = odirp->file_dta.size; /* size of file */
-
- pcdir_Join(file_info->spec, sizeof(file_info->spec), odirp->path,
- odirp->file_dta.name); /* name of file */
- pcdir_StripCase(file_info->spec);
- }
-
- return(foundone);
- }
- /* -------------------------------------------------------------------------- */
-
- void pcdir_Close(odir_type odirp)
- /*
- This routine closes an oakland directory stream and frees all resources
- it used.
-
- It's single parameter is the hanlde to the stream to close.
- */
- {
- if (odirp != NULL) {
- ofree(ID_ODIR, odirp);
- }
- return;
- }
- /* -------------------------------------------------------------------------- */
-
- boolean pcfile_Remove(char *fname_spec)
- /*
- This routine removes (deletes) the specified file from the file system.
-
- It's single parameter is a string specifing a path to the file to be
- removed.
-
- It returns TRUE if the removal took place succesfully, FALSE otherwise.
- */
- {
- OREGS regs;
-
- regs.h.ah = DOS_DELETE;
- regs.a.esdx = fname_spec; /* ds:dx -> spec */
- regs.x.ds = regs.x.es;
-
- return((oakint86ds(DOS_INT, ®s, 0) & CARRYMASK) ? TRUE : FALSE);
- }
- /* -------------------------------------------------------------------------- */
-
- boolean pcfile_IsValid(char *name, boolean wildok)
- /*
- determines if a filename is valid under the operating system.
- */
- {
- char goodchrs[13];
- int i, dots, dot = -1;
-
- if (wildok == TRUE) {
- strcpy(goodchrs, "@!-{}_`^~.*?");
- }
- else {
- strcpy(goodchrs, "@!-{}_`^~.");
- }
-
- for (dots = i = 0; name[i] != '\0'; i++) {
- if (!(name[i] > 64 && name[i] < 91) /* [a-z] */
- && !(name[i] > 96 && name[i] < 123) /* [A-Z] */
- && !(name[i] > 47 && name[i] < 58) /* [0-9] */
- && !(name[i] > 34 && name[i] < 42) /* [#$%&'()] */
- && !strchr(goodchrs, name[i])) {
-
- return(FALSE);
- }
-
- /* only one dot allowed and not in the first position */
- if (name[i] == '.') {
- if (++dots > 1 || i == 0) {
-
- return(FALSE);
- }
-
- dot = i;
- }
- }
-
- if (dot == -1) { /* there was no dot */
- if (i > 8) {
-
- return(FALSE);
- }
- }
- else if (i - dot > 4 || dot > 8) {
-
- return(FALSE);
- }
-
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
- boolean pcdir_IsValid(char *dir)
- /*
- determines if a directory is valid under the operating system.
- */
- {
- char *s, *start;
- int i;
-
- /* empty string is valid (current dir) */
- if (*dir == '\0') {
- return(TRUE);
- }
-
- s = dir;
-
- /* drive */
- if (isalpha(*s) && *(s + 1) == ':') {
- s += 2;
- }
-
- /* main loop */
- while (*s != '\0') {
-
- /* slash */
- if (*s == OFILE_SEPCHAR) {
- s++;
-
- /* skip all adjacent slashs */
- while (*s == OFILE_SEPCHAR) {
- s++;
- }
- }
-
- /* directories */
- start = s;
-
- for (i = 0; *s != '\0' && *s != '.' && *s != OFILE_SEPCHAR; s++) {
-
- /* is this a legal directory char */
- if ((*s > 64 && *s < 91) /* [a-z] */
- || (*s > 96 && *s < 123) /* [A-Z] */
- || (*s > 47 && *s < 58) /* [0-9] */
- || (*s > 34 && *s < 42) /* [#$%&'()] */
- || strchr("@!-{}_`^~", *s)) {
-
- i++;
- if (i == 8) {
- /* skip till '.', OFILE_SEPCHAR or '\0' */
- for (s++; *s != '.' && *s != '\0' && *s != OFILE_SEPCHAR; s++)
- ;
- break;
- }
- }
- else {
- return(FALSE);
- }
- }
-
- /* now where at either a '.', OFILE_SEPCHAR or '\0' in the source string */
-
- /* dot */
- /* '..' = parent directory case */
- if (*s == '.' && *(s + 1) == '.'
- && (*(s + 2) == OFILE_SEPCHAR || *(s + 2) == '\0')) {
- s += 2;
- continue;
- }
-
- /* '.' = current directory case */
- if (*s == '.' && (*(s + 1) == OFILE_SEPCHAR || *(s + 1) == '\0')) {
- s++;
- continue;
- }
-
- if (*s == '.') {
-
- /* if the dot is the first char, this spec is invalid */
- if (s == start) {
- return(FALSE);
- }
- s++;
-
- /* dot not allowed in last position */
- if (*s == OFILE_SEPCHAR || *s == '\0') {
- return(FALSE);
- }
-
- /* extention */
- for (i = 0; *s != '\0' && *s != OFILE_SEPCHAR; s++) {
-
- /* is this a legal directory char */
- if ((*s > 64 && *s < 91) /* [a-z] */
- || (*s > 96 && *s < 123) /* [A-Z] */
- || (*s > 47 && *s < 58) /* [0-9] */
- || (*s > 34 && *s < 42) /* [#$%&'()] */
- || strchr("@!-{}_`^~", *s)) {
-
- i++;
- if (i > 3) {
- return(FALSE);
- }
- }
- else {
- return(FALSE);
- }
- }
- }
- }
-
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
- boolean pcdir_MakePath(char *dirbuf, int buflen, char *dir)
- /*
- if the supplied string is not empty, we modify it to indicate a path
- */
- {
- int dirlen;
-
- if (*dir == '\0') {
- *dirbuf = '\0';
-
- return(TRUE);
- }
-
- dirlen = strlen(dir);
-
- if (dir[dirlen - 1] == OFILE_SEPCHAR) {
- if (buflen > dirlen) {
- if (dirbuf != dir) {
- strcpy(dirbuf, dir);
- }
-
- return(TRUE);
- }
- }
- else {
- if (buflen > dirlen + 1) {
- if (dirbuf != dir) {
- strcpy(dirbuf, dir);
- }
- dirbuf[dirlen] = OFILE_SEPCHAR;
- dirbuf[dirlen + 1] = '\0';
-
- return(TRUE);
- }
- }
- return(FALSE);
- }
- /* -------------------------------------------------------------------------- */
-
- boolean pcdir_Ascend(char *newpath, int maxnewpath, char *oldpath)
- /*
- This routine forms a string representing the path to the parent directory
- of the path represented by the given string. It does no checking with
- the directory system to verify either of the paths are valid; It simply
- minipulates the strings.
-
- The first parameter points to the location where the result string should
- be stored.
-
- The second parameter is the size of the available space pointer to by
- the first parameter.
-
- The third parameter is the supplied string representing the starting path.
- The path must end with the separator character for paths of the operating
- system and be null terminated. Under Dos the is '\\'.
-
- It returns TRUE if successful, FALSE otherwise.
- */
- {
- int i; /* the new path length */
-
- pcdir_MakePath(newpath, maxnewpath, oldpath);
- i = strlen(newpath);
-
- /* can't ascend above root directory */
- if ((i == 1 && newpath[0] == OFILE_SEPCHAR)
- || (i == 3 && isalpha(newpath[0]) && newpath[1] == ':'
- && newpath[2] == OFILE_SEPCHAR)) {
-
- return(FALSE);
- }
-
- /* if there isn't a subdir availiable to chop, append "../" to ascend */
- if (i == 0 || (newpath[i - 2] == '.' && newpath[i - 3] == '.')) {
- if (i + 3 <= maxnewpath) {
-
- /* strcat "../" */
- newpath[i] = '.';
- newpath[i + 1] = '.';
- newpath[i + 2] = OFILE_SEPCHAR;
- newpath[i + 3] = '\0';
-
- return(TRUE);
- }
- return(FALSE);
- }
-
- /* chop last subdir */
- for (i -= 2; newpath[i] != OFILE_SEPCHAR && newpath[i] != ':' && i > 0; i--)
- ;
- if (newpath[i] == OFILE_SEPCHAR || newpath[i] == ':') {
- newpath[i + 1] = '\0';
- }
- else {
- *newpath = '\0';
- }
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
- boolean pcdir_Descend(char *newpath, int maxnewpath, char *oldpath, char *subdir)
- /*
- This routine forms a string representing the path to a child directory
- of the path represented by the given string. It does no checking with
- the directory system to verify either of the paths are valid; It simply
- minipulates the strings.
-
- The first parameter points to the location where the result string should
- be stored.
-
- The second parameter is the size of the available space pointer to by
- the first parameter.
-
- The third parameter is the supplied string representing the starting path.
- The path must end with the separator character for paths of the operating
- system and be null terminated. Under Dos the is '\\'.
-
- The fourth parameter is a string indicating into which subdirectory
- to descend
-
- It returns TRUE if successful, FALSE otherwise.
- */
- {
- int oldpathlen, subdirlen;
-
- oldpathlen = strlen(oldpath);
- subdirlen = strlen(subdir);
-
- if (oldpathlen + subdirlen < maxnewpath) {
- if (newpath != oldpath) {
- strcpy(newpath, oldpath);
- }
- newpath += oldpathlen;
- strcpy(newpath, subdir);
- newpath += subdirlen;
- if (*(newpath - 1) != OFILE_SEPCHAR) {
- *newpath = OFILE_SEPCHAR;
- newpath++;
- }
- *newpath = '\0';
- return(TRUE);
- }
- return(FALSE);
- }
- /* -------------------------------------------------------------------------- */
-
- boolean pcdir_Split(char *spec, char *path, int maxpath, char *name, int maxname)
- /*
- This routine separates a string representing a file spec into a string
- representing the path of the spec and a string representing the filename
- of the spec. If supplied with only a filename, it sets the path to "".
- If supplied with only a path (terminated with the operating systems path
- separator character), it sets the filename to "". If supplied with "", it
- sets both the path and name to "". It does no checking with the directory
- system to verify either the path or the filename is valid; It simply
- manipulates the strings.
-
- The first parameter is the supplied file spec.
-
- The second parameter points to the location where the result path
- string should be stored, it can be NULL if the path is to be ignored.
-
- The third parameter is the size of the available space pointed to by
- the second parameter. If the second parameter is NULL, the value of
- this parameter is ignored.
-
- The fourth parameter points to the location where the result filename
- string should be stored, it can be NULL if the name is to be ignored.
-
- The fifth parameter is the size of the available space pointed to by
- the fourth parameter. If the fourth parameter is NULL, the value of
- this parameter is ignored.
-
-
- It returns TRUE if successful, FALSE otherwise.
- */
- {
- int pathlen, namelen, i, last = -1, colon = -1;
-
- if (spec == NULL) {
- return(FALSE);
- }
-
- for (i = 0; spec[i] != '\0'; i++) {
- if (spec[i] == OFILE_SEPCHAR) {
- last = i;
- }
- else if (spec[i] == ':') {
- colon = i;
- }
- }
-
- if (last != -1) { /* path and name provided */
- pathlen = last + 1;
- namelen = strlen(spec + last + 1);
-
- if (path != NULL) {
- if (pathlen < maxpath) {
- strncpy(path, spec, pathlen);
- path[pathlen] = '\0';
- }
- else {
- return(FALSE);
- }
- }
- if (name != NULL) {
- if (namelen < maxname) {
- strcpy(name, spec + last + 1);
- }
- else {
- return(FALSE);
- }
- }
- }
- else { /* only name provided */
- if (colon == -1) {
- if (path != NULL) {
- *path = '\0';
- }
- if (name != NULL) {
- if (strlen(spec) < maxname) {
- strcpy(name, spec);
- }
- else {
- return(FALSE);
- }
- }
- }
- else { /* there is a colon but no slash's */
- pathlen = colon + 1;
- namelen = strlen(spec + colon + 1);
-
- if (path != NULL) {
- if (pathlen < maxpath) {
- strncpy(path, spec, pathlen);
- path[pathlen] = '\0';
- }
- else {
- return(FALSE);
- }
- }
- if (name != NULL) {
- if (namelen < maxname) {
- strcpy(name, spec + colon + 1);
- }
- else {
- return(FALSE);
- }
- }
- }
- }
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
- boolean pcdir_Join(char *spec, int maxspec, char *path, char *name)
- /*
- This routine connects a string representing the path of a spec and
- a string representing the filename of a spec to form a string representing
- a complete file spec. It does no checking with the directory system to
- verify either of the paths or the filename are valid;
- It simply minipulates the strings. The first and third parameters or
- the first and fourth parameters are allowed to point to the same space
- since they may all be paths.
-
- The first parameter points to the location where the result spec
- string should be stored.
-
- The second parameter is the size of the available space pointer to by
- the first parameter.
-
- The third parameter is the supplied path.
-
- The fourth parameter is the supplied filename.
-
- It returns TRUE if successful, FALSE otherwise.
- */
- {
- int pathlen, namelen;
- char strbuf[OFILE_PATHLEN];
-
- pathlen = strlen(path);
- namelen = strlen(name);
-
- if (pathlen + namelen < maxspec) {
- strcpy(strbuf, path);
- strcat(strbuf, name);
- strcpy(spec, strbuf);
- return(TRUE);
- }
- else {
- return(FALSE);
- }
- }
- /* -------------------------------------------------------------------------- */
-
- char *pcdir_StripCase(char *str)
- /*
- This function converts all uppercase characters in the supplied string
- into lowercase.
- */
- {
- char *string = str;
-
- for (;*str != '\0'; str++) {
- *str = (char)otolower(*str);
- }
- return(string);
- }
- /* -------------------------------------------------------------------------- */
-
- boolean pcdir_GetCurrDir(char *buf, int len)
- {
- OREGS regs;
- boolean ret;
-
- if (len >= 64 + 3) { /* path + 'a:\' */
-
- regs.h.ah = DOS_GETDRIVE;
- oakint86ds(DOS_INT, ®s, 0);
- *buf = 'a' + regs.h.al;
- *(buf + 1) = ':';
- *(buf + 2) = OFILE_SEPCHAR;
-
- regs.h.ah = DOS_GETCD;
- regs.a.esdx = buf + 3; /* ds:si -> buf + 3 */
- regs.x.ds = regs.x.es;
- regs.x.si = regs.x.dx;
- regs.h.dl = 0; /* default drive */
-
- ret = (oakint86ds(DOS_INT, ®s, 0) & CARRYMASK) ? FALSE : TRUE;
-
- if (ret == TRUE) {
- pcdir_StripCase(buf + 3);
- }
- return(ret);
- }
- return(FALSE);
- }
-
- /* -------------------------------------------------------------------------- */
-
- static boolean typemask(byte type, byte mask)
- /*
- This function is used by ofile_Read to decide if given files type
- satisfies the type filter for the directory stream.
- */
- {
- if (mask & OFILE_ALL) {
- return(TRUE);
- }
-
- if ((type & DOS_HIDDEN) || (type & DOS_LABEL)) {
- return(FALSE);
- }
-
- if ((mask & OFILE_FILES) && !(type & DOS_SDIR)) {
- return(TRUE);
- }
-
- if ((mask & OFILE_DIRS) && (type & DOS_SDIR)) {
- return(TRUE);
- }
- return(FALSE);
- }
- /* -------------------------------------------------------------------------- */
-
-