Subversion Repositories SvarDOS

Rev

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

Rev 2048 Rev 2053
Line 38... Line 38...
38
#include "dosdisk.h"
38
#include "dosdisk.h"
39
 
39
 
40
#define searchAttr ( FILE_A_DIR | FILE_A_HIDDEN | FILE_A_SYSTEM | FILE_A_READONLY | FILE_A_ARCH )
40
#define searchAttr ( FILE_A_DIR | FILE_A_HIDDEN | FILE_A_SYSTEM | FILE_A_READONLY | FILE_A_ARCH )
41
 
41
 
42
 
42
 
43
/* copy old style findfirst data FFDTA to a WIN32_FIND_DATA
-
 
44
 * NOTE: does not map exactly.
-
 
45
 * internal to this module only.
-
 
46
 */
-
 
47
static void copyFileData(struct WIN32_FIND_DATA *findData, const struct FFDTA *finfo)
-
 
48
{
-
 
49
  /* Copy requried contents over into required structure */
-
 
50
  strcpy(findData->cFileName, finfo->ff_name);
-
 
51
  findData->attrib = finfo->ff_attr;
-
 
52
 
-
 
53
  /* copy over rest (not quite properly) */
-
 
54
  findData->ftCreationTime.ldw[0] = finfo->ff_ftime;
-
 
55
  findData->ftLastAccessTime.ldw[0] = finfo->ff_ftime;
-
 
56
  findData->ftLastWriteTime.ldw[0] = finfo->ff_ftime;
-
 
57
  findData->ftCreationTime.ldw[1] = finfo->ff_fdate;
-
 
58
  findData->ftLastAccessTime.ldw[1] = finfo->ff_fdate;
-
 
59
  findData->ftLastWriteTime.ldw[1] = finfo->ff_fdate;
-
 
60
  findData->ftCreationTime.hdw = 0;
-
 
61
  findData->ftLastAccessTime.hdw = 0;
-
 
62
  findData->ftLastWriteTime.hdw = 0;
-
 
63
  findData->nFileSizeHigh = 0;
-
 
64
  findData->nFileSizeLow = (DWORD)finfo->ff_fsize;
-
 
65
  findData->dwReserved0 = 0;
-
 
66
  findData->dwReserved1 = 0;
-
 
67
}
-
 
68
 
-
 
69
struct FFDTA *FindFirstFile(const char *pathname, struct WIN32_FIND_DATA *findData)
43
struct FFDTA *FindFirstFile(const char *pathname, struct FFDTA *findData) {
70
{
-
 
71
  static char path[1024];
44
  static char path[1024];
72
  struct FFDTA *hnd;
45
  struct FFDTA *hnd;
73
  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 */
74
 
47
 
75
  /* verify findData is valid */
48
  /* verify findData is valid */
Line 81... Line 54...
81
 
54
 
82
  /* initialize structure (clear) */
55
  /* initialize structure (clear) */
83
  /* hnd->handle = 0;  hnd->ffdtaptr = NULL; */
56
  /* hnd->handle = 0;  hnd->ffdtaptr = NULL; */
84
  memset(hnd, 0, sizeof(*hnd));
57
  memset(hnd, 0, sizeof(*hnd));
85
 
58
 
86
  /* Clear findData, this is to fix a glitch under NT, with 'special' $???? files */
-
 
87
  memset(findData, 0, sizeof(struct WIN32_FIND_DATA));
-
 
88
 
-
 
89
  /* if pathname ends in \* convert to \*.* */
59
  /* if pathname ends in \* convert to \*.* */
90
  strcpy(path, pathname);
60
  strcpy(path, pathname);
91
  {
61
  {
92
  int eos = strlen(path) - 1;
62
  int eos = strlen(path) - 1;
93
  if ((path[eos] == '*') && (path[eos - 1] == '\\')) strcat(path, ".*");
63
  if ((path[eos] == '*') && (path[eos - 1] == '\\')) strcat(path, ".*");
Line 148... Line 118...
148
    free(hnd);
118
    free(hnd);
149
    return(NULL);
119
    return(NULL);
150
  }
120
  }
151
 
121
 
152
  /* copy its results over */
122
  /* copy its results over */
153
  copyFileData(findData, hnd);
123
  memcpy(findData, hnd, sizeof(struct FFDTA));
154
 
124
 
155
  return hnd;
125
  return hnd;
156
}
126
}
157
 
127
 
158
 
128
 
159
int FindNextFile(struct FFDTA *hnd, struct WIN32_FIND_DATA *findData) {
129
int FindNextFile(struct FFDTA *hnd, struct FFDTA *findData) {
160
  short cflag = 0;  /* used to indicate if dos findnext succesful or not */
130
  short cflag = 0;  /* used to indicate if dos findnext succesful or not */
161
 
131
 
162
  /* if bad handle given return */
132
  /* if bad handle given return */
163
  if (hnd == NULL) return 0;
133
  if (hnd == NULL) return 0;
164
 
134
 
165
  /* verify findData is valid */
135
  /* verify findData is valid */
166
  if (findData == NULL) return 0;
136
  if (findData == NULL) return 0;
167
 
137
 
168
  /* Clear findData, this is to fix a glitch under NT, with 'special' $???? files */
-
 
169
  memset(findData, 0, sizeof(struct WIN32_FIND_DATA));
-
 
170
 
-
 
171
  { /* Use DOS (0x4F) findnext, returning if error */
138
  { /* Use DOS (0x4F) findnext, returning if error */
172
    unsigned short dta_seg = FP_SEG(hnd);
139
    unsigned short dta_seg = FP_SEG(hnd);
173
    unsigned short dta_off = FP_OFF(hnd);
140
    unsigned short dta_off = FP_OFF(hnd);
174
    _asm {
141
    _asm {
175
      push ax
142
      push ax
Line 209... Line 176...
209
  }
176
  }
210
 
177
 
211
  if (cflag) return 0;
178
  if (cflag) return 0;
212
 
179
 
213
  /* copy its results over */
180
  /* copy its results over */
214
  copyFileData(findData, hnd);
181
  memcpy(findData, hnd, sizeof(struct FFDTA));
215
 
182
 
216
  return 1;
183
  return 1;
217
}
184
}
218
 
185
 
219
 
186
 
Line 222... Line 189...
222
  /* 1st check if valid handle given */
189
  /* 1st check if valid handle given */
223
  if (hnd == NULL) return;
190
  if (hnd == NULL) return;
224
  free(hnd);                    /* Free memory used for the handle itself */
191
  free(hnd);                    /* Free memory used for the handle itself */
225
}
192
}
226
 
193
 
227
#include <stdio.h>
-
 
228
 
194
 
229
/**
195
/**
230
 Try LFN getVolumeInformation 1st
196
 Try LFN getVolumeInformation 1st
231
 if successful, assume valid drive/share (ie will return 1 unless error getting label)
197
 if successful, assume valid drive/share (ie will return 1 unless error getting label)
232
 if failed (any error other than unsupported) return 0
198
 if failed (any error other than unsupported) return 0