Re: Programming in standard c



On Dec 28, 1:01 pm, "Serve La" <n...@xxxxxxx> wrote:
"user923005" <dcor...@xxxxxxxxx> schreef in berichtnews:98fef529-1ad1-4870-8760-7f877834452b@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Dec 27, 2:01 pm, jacob navia <ja...@xxxxxxxxxx> wrote:





user923005 wrote:
Here is a machine (HP RX/1600 Itanium running OpenVMS) that reports
its file sizes in blocks.

[big snip]

Total of 28 files, 4404 blocks.
Next Cmd:

each of those file sizes is 512 byte increments. You can buy a new
one today from HP, if you want.
http://h71000.www7.hp.com/openvms/hw_supportchart.html

If you have one of that systems and your trash is full so you can't get
rid of it, then you can do the following

http://h71000.www7.hp.com/wizard/wiz_5424.html
Obtaining RMS file size?
Hello Mr Wizard

I am looking for a method of obtaining the size of a file, NOT the
allocation
from within a Fortran routine. I thought this would be a simple
trivial task
but alas I am proved wrong.

Can you help.

Regards Jim
Answer
RMS does NOT keep track of the number of user data bytes in a file.
The only reliable way to obtain that, is to read the file and count!

So there you have the answer!

If you are using that system expect that filesize() will take some time.

So What?

Should we ALL suffer because some brain-dead system exists somewhere?

remove() is in the standard while there are lots of systems without a
filesystem and where remove doesnt have any meaning. I happen to work on on
such a system now but I dont know what remove does because I just dont need
it and never checked. I'm guessing it returns -1
So why cant a function like filesize() be added? On systems where its
meaningless it could return an error and the programmer can take over with
the byte by byte read or whatever works for him when filesize returned an
error. Whats the logic for adding remove and not adding filesize?

Because filesize can never be anything but an estimate {in the generic
case}. For special types of files, it has meaning. For other file
types it is begging for trouble.

Back to the original question (reading a file into memory), for
systems where this is sensible to do, there is going to exist a memory
map method. Memory mapping can be made relatively portable. That is
a far more sensible solution than simply trying to read a file into
memory (note: memory mapping does a lot more than just reading a file
into memory).

I think that adding a function to the standard library that produces
an unreliable answer has limited utility. The cases where we need the
absolute number will also require lots of guarantees about the file
properties. It is starting to smell operating system specific, n'est
ce pas? For example, someone might use that number to try to read the
file into memory. That is clearly a mistake. Instead, they should
memory map the file if their system supports it.

I guess that filesize() is not in the standard because the C language
implementors thought about it and realized that people might try to
use it. Then, they will have thousands of support calls to handle
when things go wrong.

On the other hand, I think that there was a call somewhere in this
thread for fileinformation() which I think might be a very nice
addition. I guess that even filesize() might not be so bad if they
renamed it currentfilesize(). Then (at least) it would be obvious
that it only contains an estimate.
.



Relevant Pages

  • Re: Programming in standard c
    ... you would not want to put this file into memory even if you ... This DBMS doesnt come with an API to update the database? ... The reasons for not including a function like filesize in the standard are getting funnier by the minute. ...
    (comp.lang.c)
  • CreateFileMapping Question
    ... PAGE_READWRITE, 0, FileSize, FM_SCOPEMAPFILENAME); ... but I'm concerned about memory leaks. ... process closes all it's handles before the second process opens the memory ... When the first process is ...
    (microsoft.public.vc.mfc)
  • Allocating Memory in DOS
    ... I'm doing a very basic dos app that reads a file in to memory. ... But I would like to allocate memory on-the-fly, ... filesize, so I have tried to use INT 21h AH=48h. ... Carry flag is set! ...
    (comp.lang.asm.x86)
  • Re: PHP sucks!!!!!!
    ... >Seems that you don't understand PHP. ... A request never frees memory, ... memory limit: 8M ... test.txt filesize: 16200000 ...
    (comp.lang.php)
  • Re: Future of 64 bits
    ... The marketting folk have "stolen" the term 64-bit so that it has almost ... no actual technical meaning these days. ... Are you using more than 2 gb of memory in a single application? ... that things run faster because of wider bus widths. ...
    (comp.sys.mac.system)

Loading