BOOL MYRTLEXP GetFileAttr( CONSTSTR fname,ATTR_TYPE& at ) { #if defined(__GNUC__) || defined(__QNX__) struct stat s; if ( !FIO_STAT(fname,&s) ) return FALSE; at = s.st_mode; return TRUE; #else #if defined(__REALDOS__) || defined(__HWIN16__) struct ffblk f; if ( findfirst( fname,&f,-1 ) != 0 ) return FALSE; at = f.ff_attrib; return TRUE; #else #if defined(__PROTDOS__) struct find_t f; if ( _dos_findfirst( fname,-1,&f ) != 0 ) return FALSE; at = f.attrib; return TRUE; #else #if defined(__HWIN32__) at = GetFileAttributes( fname ); if ( at == MAX_DWORD ) return FALSE; return TRUE; #else #error ERR_PLATFORM #endif #endif #endif #endif }
DWORD MYRTLEXP FileLength( CONSTSTR fname ) { struct stat st; if ( !FIO_STAT( fname,&st ) ) return MAX_DWORD; #if defined(__QNX__) int file; DWORD sz; if ( S_ISLNK(st.st_mode) ) { int file = FIO_OPEN( fname,O_RDONLY ); if ( file == -1 ) return MAX_DWORD; sz = filelength( file ); FIO_CLOSE(file); return sz; } #endif return st.st_size; }
BOOL MYRTLEXP isReadOnly( CONSTSTR fname ) { struct stat stbuf; return ( FIO_STAT(fname,&stbuf) && !IS_FLAG(stbuf.st_mode,S_IWRITE) ); }