Besides reading directory entries, there used to be a method to open file, seek to end and read position. This may fail on locked file.
On Nov 30, 2008, at 22:00, "Don Guinn" <[EMAIL PROTECTED]> wrote: Here is the problem: Given a file in the current directory "xxx" is opened in one J session then tried to get it's size using bigfiles in another session. Session 0: h=:1!:21<'xxx' h 34035648 Session 1: load 'C:\j602\system\packages\files\bigfiles.ijs' fdir 'xxx' +---+-------------------+-+---+------+ |xxx|2006 12 15 10 41 25|3|rw-|-----a| +---+-------------------+-+---+------+ bfsize_jbf_ 'xxx' +--+---------------------------------------------------------------------------------+ |32|The process cannot access the file because it is being used by another process. | +--+---------------------------------------------------------------------------------+ Notice that somehow fdir is able to get the size of the file but bfsize_jbf_ is not. Back to session 0: 1!:22 h 1 And now in session 1: bfsize_jbf_ 'xxx' 0 3 Once the file is closed in session 0 the file is accessible to bigfiles. How is fdir able to get to the file size? Is it reading the directory directly avoiding having to open the file? Or what? On Sun, Nov 30, 2008 at 7:43 PM, David Mitchell <[EMAIL PROTECTED]>wrote: Don Guinn wrote: I ran into problems when using fdir (1!:0) when the files were larger than 2 gig. The size of the file is wrong as is documented. I addressed this by using bigfiles and it worked well until I tried to get the size of a file that was open by another application. Then bfsize_jbf_ fails. What confuses me is that somehow 1!:0 can retrieve the size of the file (though incorrect) even though it is open to another application. As best as I can tell all file tools provided by Microsoft require file handles implying that the file has been opened. So how does 1!:0 get the file size for files open to other applications? It would be nice if bigfiles could use the same technique. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm This worked for me: FindFirstFile=: 'kernel32 FindFirstFileA i *c *'&cd FindClose=: 'kernel32 FindClose i i'&cd findd=:318$'a' ffsize=:28+i.8 INVALID_HANDLE_VALUE=: _1 NB. ========================================================= NB.*fffsize v get file size using windows API NB. form: fffsize file_path_name fffsize=: 3 : 0 'fh ft fv'=. FindFirstFile y;findd if. INVALID_HANDLE_VALUE~:fh do. r=.b32to64 ctoi"1]2 4$ffsize{fv FindClose fh else. r=.'' end. r ) -- David Mitchell ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
