mirror of
https://github.com/libretro/xmil-libretro.git
synced 2024-11-23 08:09:42 +00:00
Eliminate file_attr
This commit is contained in:
parent
be6a9592fe
commit
3aae993397
11
fdd/fdd_2d.c
11
fdd/fdd_2d.c
@ -125,7 +125,6 @@ static UINT32 fdd2d_sec(FDDFILE fdd, REG8 media, UINT track, REG8 sc) {
|
||||
/* ---- */
|
||||
|
||||
BRESULT fdd2d_set(FDDFILE fdd, const OEMCHAR *fname) {
|
||||
|
||||
short attr;
|
||||
FILEH fh;
|
||||
UINT fdsize;
|
||||
@ -133,11 +132,19 @@ const _XDFINFO *xdf;
|
||||
const _XDFINFO *xdfterm;
|
||||
UINT size;
|
||||
|
||||
#ifndef __LIBRETRO__
|
||||
attr = file_attr(fname);
|
||||
if (attr & 0x18) {
|
||||
return(FAILURE);
|
||||
}
|
||||
#else
|
||||
attr = 0;
|
||||
#endif
|
||||
fh = file_open(fname);
|
||||
if (fh == FILEH_INVALID) {
|
||||
attr |= FILEATTR_READONLY;
|
||||
fh = file_open_rb(fname);
|
||||
}
|
||||
if (fh == FILEH_INVALID) {
|
||||
return(FAILURE);
|
||||
}
|
||||
@ -153,7 +160,7 @@ const _XDFINFO *xdfterm;
|
||||
if (size == fdsize) {
|
||||
file_cpyname(fdd->fname, fname, sizeof(fdd->fname));
|
||||
fdd->type = DISKTYPE_BETA;
|
||||
fdd->protect = (UINT8)(attr & 1);
|
||||
fdd->protect = (UINT8)(attr & FILEATTR_READONLY);
|
||||
fdd->seek = fdd2d_seek;
|
||||
fdd->read = fdd2d_read;
|
||||
fdd->write = fdd2d_write;
|
||||
|
@ -459,17 +459,25 @@ const _D88SEC *sec;
|
||||
/* ---- */
|
||||
|
||||
BRESULT fddd88_set(FDDFILE fdd, const OEMCHAR *fname) {
|
||||
|
||||
short attr;
|
||||
FILEH fh;
|
||||
BOOL r;
|
||||
UINT8 ptr[D88_TRACKMAX][4];
|
||||
UINT i;
|
||||
|
||||
#ifndef __LIBRETRO__
|
||||
attr = file_attr(fname);
|
||||
if (attr & 0x18) {
|
||||
goto fdst_err;
|
||||
}
|
||||
#else
|
||||
attr = 0;
|
||||
#endif
|
||||
fh = file_open(fname);
|
||||
if (fh == FILEH_INVALID) {
|
||||
attr |= FILEATTR_READONLY;
|
||||
fh = file_open_rb(fname);
|
||||
}
|
||||
fh = file_open_rb(fname);
|
||||
if (fh == FILEH_INVALID) {
|
||||
goto fdst_err;
|
||||
@ -486,10 +494,10 @@ BRESULT fddd88_set(FDDFILE fdd, const OEMCHAR *fname) {
|
||||
fdd->inf.d88.ptr[i] = LOADINTELDWORD(ptr[i]);
|
||||
}
|
||||
if (fdd->inf.d88.head.protect & 0x10) {
|
||||
attr |= 1;
|
||||
attr |= FILEATTR_READONLY;
|
||||
}
|
||||
fdd->type = DISKTYPE_D88;
|
||||
fdd->protect = (UINT8)(attr & 1);
|
||||
fdd->protect = (UINT8)(attr & FILEATTR_READONLY);
|
||||
fdd->seek = fddd88_seek;
|
||||
fdd->read = fddd88_read;
|
||||
fdd->write = fddd88_write;
|
||||
|
@ -212,43 +212,6 @@ UINT file_getsize(FILEH handle) {
|
||||
}
|
||||
}
|
||||
|
||||
short file_attr(const char *path) {
|
||||
|
||||
struct stat sb;
|
||||
short attr;
|
||||
|
||||
#if defined(WIN32) && defined(OSLANG_UTF8)
|
||||
char sjis[MAX_PATH];
|
||||
codecnv_utf8tosjis(sjis, SDL_arraysize(sjis), path, (UINT)-1);
|
||||
if (stat(sjis, &sb) == 0)
|
||||
#else
|
||||
if (stat(path, &sb) == 0)
|
||||
#endif
|
||||
{
|
||||
#if defined(WIN32)
|
||||
if (sb.st_mode & _S_IFDIR) {
|
||||
attr = FILEATTR_DIRECTORY;
|
||||
}
|
||||
else {
|
||||
attr = 0;
|
||||
}
|
||||
if (!(sb.st_mode & S_IWRITE)) {
|
||||
attr |= FILEATTR_READONLY;
|
||||
}
|
||||
#else
|
||||
if (S_ISDIR(sb.st_mode)) {
|
||||
return(FILEATTR_DIRECTORY);
|
||||
}
|
||||
attr = 0;
|
||||
if (!(sb.st_mode & S_IWUSR)) {
|
||||
attr |= FILEATTR_READONLY;
|
||||
}
|
||||
#endif
|
||||
return(attr);
|
||||
}
|
||||
return(-1);
|
||||
}
|
||||
|
||||
static BRESULT cnv_sttime(time_t *t, DOSDATE *dosdate, DOSTIME *dostime) {
|
||||
|
||||
struct tm *ftime;
|
||||
|
@ -77,7 +77,6 @@ UINT file_write(FILEH handle, const void *data, UINT length);
|
||||
short file_close(FILEH handle);
|
||||
UINT file_getsize(FILEH handle);
|
||||
short file_getdatetime(FILEH handle, DOSDATE *dosdate, DOSTIME *dostime);
|
||||
short file_attr(const char *path);
|
||||
|
||||
/* カレントファイル操作 */
|
||||
void file_setcd(const char *exepath);
|
||||
|
Loading…
Reference in New Issue
Block a user