Subversion Repositories SvarDOS

Rev

Rev 2194 | Rev 2197 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2194 Rev 2196
Line 143... Line 143...
143
}
143
}
144
 
144
 
145
 
145
 
146
/* add a new dirname to path, C:\XXX\*.EXE + YYY -> C:\XXX\YYY\*.EXE */
146
/* add a new dirname to path, C:\XXX\*.EXE + YYY -> C:\XXX\YYY\*.EXE */
147
static void path_add(char *path, const char *dirname) {
147
static void path_add(char *path, const char *dirname) {
148
  short i, ostatni = -1, slen;
148
  short i, ostatni = -1;
149
  printf("path_add(%s,%s) -> ", path, dirname);
149
  printf("path_add(%s,%s) -> ", path, dirname);
150
  /* find the last backslash */
150
  /* find the last backslash */
151
  for (i = 0; path[i] != 0; i++) {
151
  for (i = 0; path[i] != 0; i++) {
152
    if (path[i] == '\\') ostatni = i;
152
    if (path[i] == '\\') ostatni = i;
153
  }
153
  }
154
  /* abort on error */
154
  /* abort on error */
155
  if (ostatni == -1) return;
155
  if (ostatni == -1) return;
156
  /* do the trick */
156
  /* do the trick */
157
  slen = strlen(dirname);
157
  /* move ending to the right */
158
  memmove(path + ostatni + slen + 1, path + ostatni, slen + 1);
158
  memcpy_rtl(path + ostatni + strlen(dirname) + 1, path + ostatni, strlen(path + ostatni) + 1);
-
 
159
  /* fill in the space with dirname */
159
  memcpy(path + ostatni + 1, dirname, slen);
160
  memcpy_ltr(path + ostatni + 1, dirname, strlen(dirname));
160
  printf("'%s'\n", path);
161
  printf("'%s'\n", path);
161
}
162
}
162
 
163
 
163
 
164
 
164
/* take back last dir from path, C:\XXX\YYY\*.EXE -> C:\XXX\*.EXE */
165
/* take back last dir from path, C:\XXX\YYY\*.EXE -> C:\XXX\*.EXE */
165
static void path_back(char *path) {
166
static void path_back(char *path) {
166
  short i, ostatni = -1, przedostatni = -1;
167
  short i, ostatni = -1, przedostatni = -1;
-
 
168
  printf("path_back(%s) -> ", path);
167
  /* find the two last backslashes */
169
  /* find the two last backslashes */
168
  for (i = 0; path[i] != 0; i++) {
170
  for (i = 0; path[i] != 0; i++) {
169
    if (path[i] == '\\') {
171
    if (path[i] == '\\') {
170
      przedostatni = ostatni;
172
      przedostatni = ostatni;
171
      ostatni = i;
173
      ostatni = i;
172
    }
174
    }
173
  }
175
  }
174
  /* abort on error */
176
  /* abort on error */
175
  if (przedostatni == -1) return;
177
  if (przedostatni == -1) return;
176
  /* do the trick */
178
  /* do the trick */
177
  for (i = przedostatni; path[i] != 0; i++) {
179
  memcpy_ltr(path + przedostatni, path + ostatni, 1 + i - ostatni);
178
    path[i] = path[ostatni++];
180
  printf("'%s'\n", path);
179
  }
-
 
180
}
181
}
181
 
182
 
182
 
183
 
183
/* parse an attr list like "Ar-hS" and fill bitfield into attrfilter_may and attrfilter_must.
184
/* parse an attr list like "Ar-hS" and fill bitfield into attrfilter_may and attrfilter_must.
184
 * /AHS   -> adds S and H to mandatory attribs ("must")
185
 * /AHS   -> adds S and H to mandatory attribs ("must")
Line 709... Line 710...
709
 
710
 
710
    do {
711
    do {
711
      /* if /S then remember first directory encountered (but not . nor ..) */
712
      /* if /S then remember first directory encountered (but not . nor ..) */
712
      if ((req.flags & DIR_FLAG_RECUR) && (buf->dirpending == 0) && (dta->attr & DOS_ATTR_DIR) && (dta->fname[0] != '.')) {
713
      if ((req.flags & DIR_FLAG_RECUR) && (buf->dirpending == 0) && (dta->attr & DOS_ATTR_DIR) && (dta->fname[0] != '.')) {
713
        buf->dirpending = 1;
714
        buf->dirpending = 1;
714
        memcpy(&(buf->dtastack[buf->dtastacklen]), dta, sizeof(struct DTA));
715
        memcpy_ltr(&(buf->dtastack[buf->dtastacklen]), dta, sizeof(struct DTA));
715
      }
716
      }
716
 
717
 
717
      /* filter out files with uninteresting attributes */
718
      /* filter out files with uninteresting attributes */
718
      if (filter_attribs(dta, req.attrfilter_must, req.attrfilter_may) == 0) continue;
719
      if (filter_attribs(dta, req.attrfilter_must, req.attrfilter_may) == 0) continue;
719
 
720
 
Line 761... Line 762...
761
 
762
 
762
    /* if /S then remember first directory encountered */
763
    /* if /S then remember first directory encountered */
763
      if ((req.flags & DIR_FLAG_RECUR) && (buf->dirpending == 0) && (dta->attr & DOS_ATTR_DIR) && (dta->fname[0] != '.')) {
764
      if ((req.flags & DIR_FLAG_RECUR) && (buf->dirpending == 0) && (dta->attr & DOS_ATTR_DIR) && (dta->fname[0] != '.')) {
764
      buf->dirpending = 1;
765
      buf->dirpending = 1;
765
      puts("GOT DIR (/S)");
766
      puts("GOT DIR (/S)");
766
      memcpy(&(buf->dtastack[buf->dtastacklen]), dta, sizeof(struct DTA));
767
      memcpy_ltr(&(buf->dtastack[buf->dtastacklen]), dta, sizeof(struct DTA));
767
    }
768
    }
768
 
769
 
769
    /* filter out attributes (skip if entry comes from buffer, then it was already veted) */
770
    /* filter out attributes (skip if entry comes from buffer, then it was already veted) */
770
    if (filter_attribs(dta, req.attrfilter_must, req.attrfilter_may) == 0) goto NEXT_ENTRY;
771
    if (filter_attribs(dta, req.attrfilter_must, req.attrfilter_may) == 0) goto NEXT_ENTRY;
771
 
772