Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Shortening file length on RandomAccessFile


  • From: rschulz@xxxxxxxxxxxxxxx (Randall Schulz)
  • Subject: Shortening file length on RandomAccessFile
  • Date: Tue, 31 Aug 1999 13:35:54 -0700

Andy, Jeff,

On the Mac and on all Unix (native) file systems, a file's size can be set
absolutely without truncating and re-writing. On the Mac the two file forks
can be manipulated independently. If I recall correctly, you can even swap
the forks. I don't know about any of the DOS/Windows-related files systems..

Of course all this would require non-portable or native (JNI) code, as Jeff
points out, but it can be done, at least on Mac and Unix (-alikes).

Randy Schulz
Teknowledge Corp.
Palo Alto, CA USA


At 01:22 PM 8/31/99 , Jeff Sturm wrote:
>There is no portable way to shorten a file.  On many platforms you must
>resort to recreating the file, even if you code in C.
>
>Andy Wiese wrote:
>> 
>> Is there a way that I can reduce the length of a RandomAccessFile? I am
>> using RandomAccessFile to implement a small database...when the total
>> stored data shrinks, I would like to reduce the length of the file. I am
>> trying to avoid writing out a new file because of cross-platform issues
>> (it needs to run well on the Mac, and if I recreate the file I lose the
>> resource fork).
>> 
>> --
>> ================
>> v. Anderson Wiese 2
>> president
>> Bluestem Inc.
>> www.bluestem.net
>> ================
>
>-- 
>Jeff Sturm
>jsturm@xxxxxxxxxx