Subversion Repositories SvarDOS

Rev

Rev 2056 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2056 Rev 2057
Line 30... Line 30...
30
 
30
 
31
 
31
 
32
/*** Expects Pointers to be near (Tiny, Small, and Medium models ONLY) ***/
32
/*** Expects Pointers to be near (Tiny, Small, and Medium models ONLY) ***/
33
 
33
 
34
#include <dos.h>
34
#include <dos.h>
-
 
35
#include <stdio.h>   /* PATH_MAX */
35
#include <stdlib.h>
36
#include <stdlib.h>
36
#include <string.h>
37
#include <string.h>
37
 
38
 
38
#include "dosdisk.h"
39
#include "dosdisk.h"
39
 
40
 
40
#define searchAttr ( FILE_A_DIR | FILE_A_HIDDEN | FILE_A_SYSTEM | FILE_A_READONLY | FILE_A_ARCH )
41
#define searchAttr ( FILE_A_DIR | FILE_A_HIDDEN | FILE_A_SYSTEM | FILE_A_READONLY | FILE_A_ARCH )
41
 
42
 
42
 
43
 
43
struct FFDTA *FindFirstFile(const char *pathname, struct FFDTA *findData) {
44
struct FFDTA *FindFirstFile(const char *pathname, struct FFDTA *hnd) {
44
  static char path[1024];
45
  char path[PATH_MAX];
45
  struct FFDTA *hnd;
-
 
46
  short cflag = 0;  /* used to indicate if findfirst is succesful or not */
46
  short cflag = 0;  /* used to indicate if findfirst is succesful or not */
47
 
47
 
48
  /* verify findData is valid */
-
 
49
  if (findData == NULL) return(NULL);
-
 
50
 
-
 
51
  /* allocate memory for the handle */
-
 
52
  hnd = malloc(sizeof(*hnd));
-
 
53
  if (hnd == NULL) return(NULL);
-
 
54
 
-
 
55
  /* initialize structure (clear) */
48
  /* initialize structure (clear) */
56
  /* hnd->handle = 0;  hnd->ffdtaptr = NULL; */
49
  /* hnd->handle = 0;  hnd->ffdtaptr = NULL; */
57
  memset(hnd, 0, sizeof(*hnd));
50
  memset(hnd, 0, sizeof(*hnd));
58
 
51
 
59
  /* if pathname ends in \* convert to \*.* */
52
  /* if pathname ends in \* convert to \*.* */
Line 112... Line 105...
112
    pop bx
105
    pop bx
113
    pop ax
106
    pop ax
114
  }
107
  }
115
  }
108
  }
116
 
109
 
117
  if (cflag) {
-
 
118
    free(hnd);
-
 
119
    return(NULL);
110
  if (cflag) return(NULL);
120
  }
-
 
121
 
-
 
122
  /* copy its results over */
-
 
123
  memcpy(findData, hnd, sizeof(struct FFDTA));
-
 
124
 
111
 
125
  return hnd;
112
  return hnd;
126
}
113
}
127
 
114
 
128
 
115
 
129
int FindNextFile(struct FFDTA *hnd, struct FFDTA *findData) {
116
int FindNextFile(struct FFDTA *hnd) {
130
  short cflag = 0;  /* used to indicate if dos findnext succesful or not */
117
  short cflag = 0;  /* used to indicate if dos findnext succesful or not */
131
 
118
 
132
  /* if bad handle given return */
119
  /* if bad handle given return */
133
  if (hnd == NULL) return 0;
120
  if (hnd == NULL) return 0;
134
 
121
 
135
  /* verify findData is valid */
-
 
136
  if (findData == NULL) return 0;
-
 
137
 
-
 
138
  { /* Use DOS (0x4F) findnext, returning if error */
122
  { /* Use DOS (0x4F) findnext, returning if error */
139
    unsigned short dta_seg = FP_SEG(hnd);
123
    unsigned short dta_seg = FP_SEG(hnd);
140
    unsigned short dta_off = FP_OFF(hnd);
124
    unsigned short dta_off = FP_OFF(hnd);
141
    _asm {
125
    _asm {
142
      push ax
126
      push ax
Line 175... Line 159...
175
    }
159
    }
176
  }
160
  }
177
 
161
 
178
  if (cflag) return 0;
162
  if (cflag) return 0;
179
 
163
 
180
  /* copy its results over */
-
 
181
  memcpy(findData, hnd, sizeof(struct FFDTA));
-
 
182
 
-
 
183
  return 1;
164
  return 1;
184
}
165
}
185
 
166
 
186
 
167
 
187
/* free resources to prevent memory leaks */
168
/* free resources to prevent memory leaks */
188
void FindClose(struct FFDTA *hnd) {
169
void FindClose(struct FFDTA *hnd) {
189
  /* 1st check if valid handle given */
170
  /* 1st check if valid handle given */
190
  if (hnd == NULL) return;
171
  if (hnd == NULL) return;
191
  free(hnd);                    /* Free memory used for the handle itself */
-
 
192
}
172
}
193
 
173
 
194
 
174
 
195
/**
175
/**
196
 Try LFN getVolumeInformation 1st
176
 Try LFN getVolumeInformation 1st