More file system primitives
Bug #295846 reported by
Andreas Rottmann
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ikarus Scheme |
Fix Committed
|
Medium
|
Abdulaziz Ghuloum |
Bug Description
It would be nice to have more file system functions; I propose the following additions:
file-readable? path -> boolean
file-writable? path -> boolean
file-executable? path -> boolean
file-size path -> integer
rename-file source dest -> undefined
With the obvious semantics.
Related branches
Changed in ikarus: | |
assignee: | nobody → aghuloum |
importance: | Undecided → Medium |
status: | New → Confirmed |
Changed in ikarus: | |
milestone: | none → 0.0.4 |
To post a comment you must log in.
On Sun, 2008-11-09 at 05:45 +0000, Andreas Rottmann wrote: launchpadlibrar ian.net/ 19504032/ filesys. patch
> ** Attachment added: "Adds a few file system primitives"
> http://
Is this a bug in the patch?:
If, on a 32-bit system, large file support is enabled (like requested at
bug #295833), thus making off_t be 64-bit, then will this result in C
numbers possibly too large for Ikarus 30-bit fixnums?:
+ikptr size(ikptr filename, ikptr res){ data);
+ikrt_file_
+ char* fn = (char*)(filename + off_bytevector_
+ struct stat s;
+ int r;
+
+ r = stat(fn, &s);
+
+ if (r == 0)
+ {
+ ref(res, off_car) = fix(s.st_size >> 24); <---- THIS
+ ref(res, off_cdr) = fix(s.st_size & ~(-1L << 24));
+ return fix(0);
+ }
+ else
+ return ik_errno_to_code();
+}
struct stat's st_size field is an off_t, and if this field is 64-bits
and we're on a 32-bit system and say the value of this field (the size
of the file) is 0x0200000000000000 (crazy, I know :), but otherwise
we're relying on the unknown variable file-system type to prevent sizes
this large), then:
s.st_size >> 24 == 0x000000020000000
which is too big for a 30-bit fixnum:
> (<= #x20000000 (greatest-fixnum))
#f
> (printf "#x~x\n" (greatest-fixnum))
#x1FFFFFFF
>
Maybe this s.st_size should be chopped into 3 pieces, or Aziz can make
it into a bignum from C if it's too big for a fixnum? What's the best
portable way?