mirror of
https://github.com/ilyakooo0/Idris-dev.git
synced 2024-08-16 12:10:39 +03:00
Fix fileModifiedTime on 32 bit systems
Can't use MKBIGI for the result, since that'll be a negative number for the current time! So use MKBIGUI instead to ensure it stays unsigned.
This commit is contained in:
parent
10fd4e71f8
commit
bbd0f286c2
@ -150,7 +150,8 @@ do_getFileAccessTime h =
|
||||
private
|
||||
do_getFileModifiedTime : Ptr -> IO Integer
|
||||
do_getFileModifiedTime h =
|
||||
do MkRaw i <- foreign FFI_C "fileModifiedTime" (Ptr -> IO (Raw Integer)) h
|
||||
do vm <- getMyVM
|
||||
MkRaw i <- foreign FFI_C "fileModifiedTime" (Ptr -> Ptr -> IO (Raw Integer)) vm h
|
||||
pure i
|
||||
|
||||
private
|
||||
@ -175,7 +176,7 @@ export
|
||||
fileModifiedTime : File -> IO (Either FileError Integer)
|
||||
fileModifiedTime (FHandle h)
|
||||
= do s <- do_getFileModifiedTime h
|
||||
if (s < 0)
|
||||
if (s == -1)
|
||||
then Left <$> getFileError
|
||||
else pure (Right s)
|
||||
|
||||
|
@ -74,13 +74,13 @@ VAL fileAccessTime(void* h) {
|
||||
}
|
||||
}
|
||||
|
||||
VAL fileModifiedTime(void* h) {
|
||||
VAL fileModifiedTime(VM* vm, void* h) {
|
||||
FILE* f = (FILE*)h;
|
||||
int fd = fileno(f);
|
||||
|
||||
struct stat buf;
|
||||
if (fstat(fd, &buf) == 0) {
|
||||
return MKBIGI(buf.st_mtime);
|
||||
return MKBIGUI(vm, buf.st_mtime);
|
||||
} else {
|
||||
return MKBIGI(-1);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ int fileSize(void* h);
|
||||
|
||||
// Return a negative number if not a file (e.g. directory or device)
|
||||
VAL fileAccessTime(void* h);
|
||||
VAL fileModifiedTime(void* h);
|
||||
VAL fileModifiedTime(VM* vm, void* h);
|
||||
VAL fileStatusTime(void* h);
|
||||
|
||||
void* idris_dirOpen(char* dname);
|
||||
|
Loading…
Reference in New Issue
Block a user