mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-10 21:55:11 +01:00
Remove RiscOS compatibility and fix warnings
This commit is contained in:
parent
e2dcd7475a
commit
33ac22c693
@ -194,7 +194,6 @@ uint8 FSDrive::open_file(int channel, const uint8 *name, int name_len)
|
||||
}
|
||||
|
||||
// Open file
|
||||
#ifndef __riscos__
|
||||
if (chdir(dir_path))
|
||||
set_error(ERR_NOTREADY);
|
||||
else if ((file[channel] = fopen(plain_name, mode_str)) != NULL) {
|
||||
@ -202,26 +201,8 @@ uint8 FSDrive::open_file(int channel, const uint8 *name, int name_len)
|
||||
read_char[channel] = fgetc(file[channel]);
|
||||
} else
|
||||
set_error(ERR_FILENOTFOUND);
|
||||
chdir(AppDirPath);
|
||||
#else
|
||||
{
|
||||
char fullname[NAMEBUF_LENGTH];
|
||||
|
||||
// On RISC OS make a full filename
|
||||
sprintf(fullname,"%s.%s",dir_path,plain_name);
|
||||
if ((file[channel] = fopen(fullname, mode)) != NULL)
|
||||
{
|
||||
if (mode == FMODE_READ || mode == FMODE_M)
|
||||
{
|
||||
read_char[channel] = fgetc(file[channel]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
set_error(ERR_FILENOTFOUND);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (chdir(AppDirPath) < 0)
|
||||
set_error(ERR_NOTREADY);
|
||||
|
||||
return ST_OK;
|
||||
}
|
||||
@ -303,11 +284,6 @@ uint8 FSDrive::open_directory(int channel, const uint8 *pattern, int pattern_len
|
||||
char str[NAMEBUF_LENGTH];
|
||||
char *p, *q;
|
||||
int i;
|
||||
int filemode;
|
||||
int filetype;
|
||||
bool wildflag;
|
||||
|
||||
#ifndef __riscos__
|
||||
DIR *dir;
|
||||
struct dirent *de;
|
||||
struct stat statbuf;
|
||||
@ -355,9 +331,11 @@ uint8 FSDrive::open_directory(int channel, const uint8 *pattern, int pattern_len
|
||||
if (match(ascii_pattern, de->d_name)) {
|
||||
|
||||
// Get file statistics
|
||||
chdir(dir_path);
|
||||
if (chdir(dir_path) < 0)
|
||||
continue;
|
||||
stat(de->d_name, &statbuf);
|
||||
chdir(AppDirPath);
|
||||
if (chdir(AppDirPath) < 0)
|
||||
continue;
|
||||
|
||||
// Clear line with spaces and terminate with null byte
|
||||
memset(buf, ' ', 31);
|
||||
@ -403,61 +381,6 @@ uint8 FSDrive::open_directory(int channel, const uint8 *pattern, int pattern_len
|
||||
// Get next directory entry
|
||||
de = readdir(dir);
|
||||
}
|
||||
#else
|
||||
dir_full_info di;
|
||||
dir_env de;
|
||||
unsigned char c;
|
||||
|
||||
// Much of this is very similar to the original
|
||||
if ((pattern[0] == '0') && (pattern[1] == 0)) {pattern++;}
|
||||
|
||||
// Concatenate dir_path and ascii_pattern in buffer ascii_pattern ==> read subdirs!
|
||||
strcpy(ascii_pattern,dir_path); i = strlen(ascii_pattern); ascii_pattern[i++] = '.'; ascii_pattern[i] = 0;
|
||||
convert_filename(pattern, ascii_pattern + i, &filemode, &filetype, &wildflag);
|
||||
p = ascii_pattern + i; q = p;
|
||||
do {c = *q++; if (c == '.') p = q;} while (c >= 32);
|
||||
*(p-1) = 0; // separate directory-path and ascii_pattern
|
||||
if ((uint8)(*p) < 32) {*p = '*'; *(p+1) = 0;}
|
||||
|
||||
// We don't use tmpfile() -- problems involved!
|
||||
DeleteFile(RO_TEMPFILE); // first delete it, if it exists
|
||||
if ((file[channel] = fopen(RO_TEMPFILE,"wb+")) == NULL)
|
||||
return(ST_OK);
|
||||
de.offset = 0; de.buffsize = NAMEBUF_LENGTH; de.match = p;
|
||||
|
||||
// Create directory title - copied from above
|
||||
p = &buf[8];
|
||||
for (i=0; i<16 && dir_title[i]; i++)
|
||||
*p++ = conv_to_64(dir_title[i], false);
|
||||
fwrite(buf, 1, 32, file[channel]);
|
||||
|
||||
do {
|
||||
de.readno = 1;
|
||||
if (ReadDirNameInfo(ascii_pattern,&di,&de) != NULL)
|
||||
de.offset = -1;
|
||||
else if (de.readno > 0) { // don't have to check for match here
|
||||
memset(buf,' ',31); buf[31] = 0; // most of this: see above
|
||||
p = buf; *p++ = 0x01; *p++ = 0x01;
|
||||
i = (di.length + 254) / 254; *p++ = i & 0xff; *p++ = (i>>8) & 0xff;
|
||||
p++;
|
||||
if (i < 10)
|
||||
*p++ = ' ';
|
||||
if (i < 100)
|
||||
*p++ = ' ';
|
||||
strcpy(str, di.name);
|
||||
*p++ = '\"'; q = p;
|
||||
for (i=0; (i<16 && str[i]); i++)
|
||||
*q++ = conv_to_64(str[i], true);
|
||||
*q++ = '\"'; p += 18;
|
||||
if ((di.otype & 2) == 0) {
|
||||
*p++ = 'P'; *p++ = 'R'; *p++ = 'G';
|
||||
} else {
|
||||
*p++ = 'D'; *p++ = 'I'; *p++ = 'R';
|
||||
}
|
||||
fwrite(buf, 1, 32, file[channel]);
|
||||
}
|
||||
} while (de.offset != -1);
|
||||
#endif
|
||||
|
||||
// Final line
|
||||
fwrite("\001\001\0\0BLOCKS FREE. \0\0", 1, 32, file[channel]);
|
||||
@ -466,10 +389,8 @@ uint8 FSDrive::open_directory(int channel, const uint8 *pattern, int pattern_len
|
||||
rewind(file[channel]);
|
||||
read_char[channel] = fgetc(file[channel]);
|
||||
|
||||
#ifndef __riscos
|
||||
// Close directory
|
||||
closedir(dir);
|
||||
#endif
|
||||
|
||||
return ST_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user