Size?
[1/15] from: eskape::tdcadsl::dk at: 10-Dec-2004 13:27
If the size of a file is larger than the max
value of an integer, how can I then retrieve
the size?
Thank you
Steffen
[2/15] from: SunandaDH:aol at: 10-Dec-2004 8:15
Stephan:
> If the size of a file is larger than the max
> value of an integer, how can I then retrieve
> the size?
I hope you get a better answer than this from someone else.....but I don't
think you can easily.
Both size? and info? assume an integer field so they fail in the same way.
You could try reading it, but that may take forever, or fail on lack of
memory:
length? read/binary %big-file
If you have Command or a recent Beta with 'Call enabled, you could issue the
appropriate operating system command and capture/parse the output -- ls or dir
etc.
It'd be worth adding a bug report to RAMBO ( www.rebol.net ) to report the
problem.
Sunanda.
[3/15] from: carl:cybercraft at: 11-Dec-2004 2:33
On Friday, 10-December-2004 at 13:27:04 you wrote,
>If the size of a file is larger than the max
>value of an integer, how can I then retrieve
>the size?
Have you tried INFO? ...
>> ? info?
USAGE:
INFO? target
DESCRIPTION:
Returns information about a file or url.
INFO? is a function value.
ARGUMENTS:
target -- (Type: file url)
(SPECIAL ATTRIBUTES)
catch
Note it returns an object. Let us know what happens if you do...
-- Carl Read.
[4/15] from: rotenca::telvia::it at: 10-Dec-2004 15:09
Hi, Sunanda,
I think that Rebol is limited for every operation to 2GB (2147483647
bytes) because internal integers are signed 32 bit.
I think this is a limit for ports, any-block and any-string length and
index.
A structural limit.
Time for a 64 bit Rebol?
[5/15] from: SunandaDH:aol at: 10-Dec-2004 10:36
Romano:
> I think that Rebol is limited for every operation to 2GB (2147483647
> bytes) because internal integers are signed 32 bit.
> I think this is a limit for ports, any-block and any-string length and
> index.
If it is a limit on the length of a string, then my suggestion (poor though
it was) to read the file and do a length? would not work. I don't have the
patience on a slowish machine to try to create a string that long to test.
I guess it would also make it hard to handle any file larger than 2Gig even
with Open/direct (which is buggy anyway for other reasons, and so inadvisable).
That would leave Steffen stymied for handling large files.
I hope it isn't a fundamental limit. Or, if it is, it's one that a little bit
of mezzanine ingenuity can work around.
Sunanda.
[6/15] from: greggirwin:mindspring at: 10-Dec-2004 10:42
Hi Steffen,
SP> If the size of a file is larger than the max
SP> value of an integer, how can I then retrieve
SP> the size?
If you have /pro, you could do it with OS calls (e.g.
GetFileAttributesEx under Windows).
-- Gregg
[7/15] from: lmecir:mbox:vol:cz at: 10-Dec-2004 22:01
Carl Read napsal(a):
>Have you tried INFO? ...
>>>? info?
<<quoted lines omitted: 11>>
>Note it returns an object. Let us know what happens if you do...
>-- Carl Read.
INFO? is a mezzanine.
source info?
-L
[8/15] from: pwawood:mango:my at: 11-Dec-2004 16:04
From Romano's comment, the 32-bit signed integer imposed 2147483647 byte
sounds extremely fundamental. I fear no amount of mezzanine sourcery can
conquer this constraint.
Perhaps one of the list guru's can prove me wrong?
Regards
Peter
[9/15] from: antonr:lexicon at: 12-Dec-2004 2:23
In my tests on WinXP, it looks like
the sensible limit is 2147483647 == to-integer #{7FFFFFFF}
However, in my tests (see code below),
the size integer returned by INFO? wraps
around to -2147483648 and continues up from
there as you increase the file size, so at least
on WinXP you can get up to 4 Gigabytes (minus 1) and still accurately
test for size (albeit with a bit of careful integer hackery).
When 4Gig is reached, the size returned is zero.
If you further increase the file size from here,
then INFO? just gives a zero size result.
Anton.
> If the size of a file is larger than the max
> value of an integer, how can I then retrieve
> the size?
>
> Thank you
>
> Steffen
(watch out for unintended line wrapping...)
rebol [
Title: ""
File: %test-max-file.r
Date: 12-Dec-2004
Version: 1.0.0
Needs: []
Author: "Anton Rolls"
Language: 'English
Purpose: {Determine maximum file size which can be tested accurately}
Usage: {}
ToDo: {
-
}
History: [
1.0.0 [12-Dec-2004 {First version} "Anton"]
]
Notes: {
In rebol, file sizes are typically stored in signed integers.
Therefore the theoretical limit is:
2147483647 == to-integer #{7FFFFFFF}
}
]
file: %/L/big-rebol-file ; <- on a volume with enough space !!
; create a large string, but not so large it exhausts our memory
block-size: 1024 * 1024 * 16 ; 16 Megabytes
str: make string! block-size ; pre-allocate the string
insert/dup str "1" block-size ; <- fill the string
str-1: copy/part str back tail str ; <- one character less
if exists? file [delete file]
expected-size: 0
repeat n 255 [ ; (also try to 127)
print [n "^-Expected size:" expected-size "^-SIZE? size:" size? file]
write/append file str
expected-size: attempt [expected-size + block-size] ; catch integer
overflow errors
]
print ["SIZE? size:" size? file]
write/append file str-1 ; just below overflow limit
print ["SIZE? size:" size? file] ; <- size comes back as a negative number
write/append file "F" ; <- this causes the size integer overflow (number
becomes negative)
print ["SIZE? size:" size? file]
write/append file "1"
print ["SIZE? size:" size? file]
;halt
[10/15] from: rotenca:telvia:it at: 11-Dec-2004 16:49
Hi, list,
This is a solution which can work until 4GB file, to find the size of a
file. The file size, now, is a decimal value. Use it at your own risk:
is an hack which makes some assumptions on Rebol file size which no one
can assure.
info4G?: func [file][
file: info? file
if file/size < 0 [file/size: 2 ** 32 + to decimal! file/size]
file
]
>> probe info4g? %golost.txt
make object! [
size: 2149300000.0
date: 1-Nov-2002/16:37:12+1:00
type: 'file
]
[11/15] from: eskape:tdcadsl:dk at: 12-Dec-2004 13:38
Hi list,
Thank you very much for your answers.
I did try all your suggestions on my own before
bothering you; but I think everybody would agree
that none are satisfactory. That's why I asked you
in the first place ;-)
Correction: I did not try to interface directly
to the O/S using /pro. I don't have /pro. I would
gladly buy it though, if I did not too often run
into glitches like this.
Anyhow, I think interfacing directly to the O/S
for a thing like this would be bad design.
This means I cannot use Rebol for any general
utility for handling files and/or directories.
I have also noticed that I only have access to
size (faulty implementation), date (modification
date only) and type.
A pity.
Thanks again - Steffen
++++++++
[12/15] from: eskape:tdcadsl:dk at: 12-Dec-2004 14:00
Hi Sunanda,
I have added a bugreport to RAMBO as you suggested.
Steffen
+++++
[SunandaDH--aol--com] wrote:
[13/15] from: antonr::lexicon::net at: 13-Dec-2004 0:29
INFO? only gives you a subset of available
file information. A set which is very cross-platform.
But see this:
>> get-modes %rebol.exe get-modes %afile 'file-modes
== [creation-date: 19-Aug-2003/12:21:03+11:00 access-date:
12-Dec-2004/23:32:12+11:00 modification-date: 31-May-2003/16:0
4:03+11:00...
These can be different depending on the host file-system.
Anton.
[14/15] from: antonr:lexicon at: 11-Dec-2004 1:49
Good question.
Is this something you're just wondering about
or is there a particular project of yours it
might affect ?
Anton.
[15/15] from: tomc:darkwing:uoregon at: 10-Dec-2004 15:59
please send more feedback to RT
http://www.rebol.net/cgi-bin/rambo.r?id=3536&
On Fri, 10 Dec 2004, Steffen Pedersen wrote:
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted