113 |
|
#else |
114 |
|
int Info[4]; |
115 |
|
|
116 |
< |
if ((ReadCatalogueInfo(dirpath,Info) & 2) != 0) // Directory or image file |
117 |
< |
{ |
118 |
< |
strcpy(dir_path, dirpath); |
119 |
< |
strncpy(dir_title, dir_path, 16); |
120 |
< |
return true; |
121 |
< |
} |
122 |
< |
else |
123 |
< |
{ |
124 |
< |
return false; |
125 |
< |
} |
116 |
> |
if ((ReadCatalogueInfo(dirpath,Info) & 2) != 0) { // Directory or image file |
117 |
> |
strcpy(dir_path, dirpath); |
118 |
> |
strncpy(dir_title, dir_path, 16); |
119 |
> |
return true; |
120 |
> |
} else |
121 |
> |
return false; |
122 |
|
#endif |
123 |
|
} |
124 |
|
|
338 |
|
char Buffer[NAMEBUF_LENGTH]; |
339 |
|
|
340 |
|
de.offset = 0; de.buffsize = NAMEBUF_LENGTH; de.match = name; |
341 |
< |
do |
342 |
< |
{ |
343 |
< |
de.readno = 1; |
344 |
< |
if (ReadDirName(dir_path,Buffer,&de) != NULL) {de.offset = -1;} |
345 |
< |
else if (de.offset != -1) |
346 |
< |
{ |
347 |
< |
if (match(name,Buffer)) |
348 |
< |
{ |
349 |
< |
strncpy(name, Buffer, NAMEBUF_LENGTH); |
354 |
< |
return; |
355 |
< |
} |
356 |
< |
} |
357 |
< |
} |
358 |
< |
while (de.offset != -1); |
341 |
> |
do { |
342 |
> |
de.readno = 1; |
343 |
> |
if (ReadDirName(dir_path,Buffer,&de) != NULL) |
344 |
> |
de.offset = -1; |
345 |
> |
else if (de.offset != -1 && match(name,Buffer)) { |
346 |
> |
strncpy(name, Buffer, NAMEBUF_LENGTH); |
347 |
> |
return; |
348 |
> |
} |
349 |
> |
} while (de.readno > 0); |
350 |
|
#endif |
351 |
|
} |
352 |
|
|
457 |
|
#else |
458 |
|
dir_full_info di; |
459 |
|
dir_env de; |
460 |
+ |
unsigned char c; |
461 |
|
|
462 |
|
// Much of this is very similar to the original |
463 |
|
if ((filename[0] == '0') && (filename[1] == 0)) {filename++;} |
464 |
+ |
|
465 |
|
// Concatenate dir_path and pattern in buffer pattern ==> read subdirs! |
466 |
< |
strcpy(pattern,dir_path); |
467 |
< |
convert_filename(filename, pattern + strlen(pattern), &filemode, &filetype, &wildflag); |
466 |
> |
strcpy(pattern,dir_path); i = strlen(pattern); pattern[i++] = '.'; pattern[i] = 0; |
467 |
> |
convert_filename(filename, pattern + i, &filemode, &filetype, &wildflag); |
468 |
> |
p = pattern + i; q = p; |
469 |
> |
do {c = *q++; if (c == '.') p = q;} while (c >= 32); |
470 |
> |
*(p-1) = 0; // separate directory-path and pattern |
471 |
> |
if ((uint8)(*p) < 32) {*p = '*'; *(p+1) = 0;} |
472 |
|
|
473 |
|
// We don't use tmpfile() -- problems involved! |
474 |
|
DeleteFile(RO_TEMPFILE); // first delete it, if it exists |
475 |
|
if ((file[channel] = fopen(RO_TEMPFILE,"wb+")) == NULL) |
476 |
< |
{ |
477 |
< |
return(ST_OK); |
481 |
< |
} |
482 |
< |
de.offset = 0; de.buffsize = NAMEBUF_LENGTH; de.match = filename; |
476 |
> |
return(ST_OK); |
477 |
> |
de.offset = 0; de.buffsize = NAMEBUF_LENGTH; de.match = p; |
478 |
|
|
479 |
|
// Create directory title - copied from above |
480 |
|
p = &buf[8]; |
482 |
|
*p++ = conv_to_64(dir_title[i], false); |
483 |
|
fwrite(buf, 1, 32, file[channel]); |
484 |
|
|
485 |
< |
do |
486 |
< |
{ |
487 |
< |
de.readno = 1; |
488 |
< |
if (ReadDirNameInfo(pattern,&di,&de) != NULL) {de.offset = -1;} |
489 |
< |
else if (de.offset != -1) // don't have to check for match here |
490 |
< |
{ |
491 |
< |
memset(buf,' ',31); buf[31] = 0; // most of this: see above |
492 |
< |
p = buf; *p++ = 0x01; *p++ = 0x01; |
493 |
< |
i = (di.length + 254) / 254; *p++ = i & 0xff; *p++ = (i>>8) & 0xff; |
494 |
< |
p++; |
495 |
< |
if (i < 10) {*p++ = ' ';} |
496 |
< |
if (i < 100) {*p++ = ' ';} |
497 |
< |
strcpy(str, di.name); |
498 |
< |
*p++ = '\"'; q = p; |
499 |
< |
for (i=0; (i<16 && str[i]); i++) |
500 |
< |
{ |
501 |
< |
*q++ = conv_to_64(str[i], true); |
502 |
< |
} |
503 |
< |
*q++ = '\"'; p += 18; |
504 |
< |
if ((di.otype & 2) == 0) |
505 |
< |
{ |
506 |
< |
*p++ = 'P'; *p++ = 'R'; *p++ = 'G'; |
507 |
< |
} |
508 |
< |
else |
509 |
< |
{ |
510 |
< |
*p++ = 'D'; *p++ = 'I'; *p++ = 'R'; |
516 |
< |
} |
517 |
< |
fwrite(buf, 1, 32, file[channel]); |
518 |
< |
} |
519 |
< |
} |
520 |
< |
while (de.offset != -1); |
485 |
> |
do { |
486 |
> |
de.readno = 1; |
487 |
> |
if (ReadDirNameInfo(pattern,&di,&de) != NULL) |
488 |
> |
de.offset = -1; |
489 |
> |
else if (de.readno > 0) { // don't have to check for match here |
490 |
> |
memset(buf,' ',31); buf[31] = 0; // most of this: see above |
491 |
> |
p = buf; *p++ = 0x01; *p++ = 0x01; |
492 |
> |
i = (di.length + 254) / 254; *p++ = i & 0xff; *p++ = (i>>8) & 0xff; |
493 |
> |
p++; |
494 |
> |
if (i < 10) |
495 |
> |
*p++ = ' '; |
496 |
> |
if (i < 100) |
497 |
> |
*p++ = ' '; |
498 |
> |
strcpy(str, di.name); |
499 |
> |
*p++ = '\"'; q = p; |
500 |
> |
for (i=0; (i<16 && str[i]); i++) |
501 |
> |
*q++ = conv_to_64(str[i], true); |
502 |
> |
*q++ = '\"'; p += 18; |
503 |
> |
if ((di.otype & 2) == 0) { |
504 |
> |
*p++ = 'P'; *p++ = 'R'; *p++ = 'G'; |
505 |
> |
} else { |
506 |
> |
*p++ = 'D'; *p++ = 'I'; *p++ = 'R'; |
507 |
> |
} |
508 |
> |
fwrite(buf, 1, 32, file[channel]); |
509 |
> |
} |
510 |
> |
} while (de.offset != -1); |
511 |
|
#endif |
512 |
|
|
513 |
|
// Final line |
711 |
|
#ifdef __riscos__ |
712 |
|
return '.'; // directory separator is '.' in RO |
713 |
|
if (c == '.') {return('_');} // convert dot to underscore |
714 |
+ |
if (c == ' ') {return(0xa0);} // space --> hard space |
715 |
|
#else |
716 |
|
return '\\'; |
717 |
|
#endif |
735 |
|
return '/'; |
736 |
|
#ifdef __riscos__ |
737 |
|
if (c == '_') {return('.');} // convert underscore to dot |
738 |
+ |
if (c == 0xa0) {return(' ');} // hard space -> space |
739 |
|
#endif |
740 |
|
return c; |
741 |
|
} |