Nice one with R function, MS!
For Windows, here is the hard way.
// filesize.jsl
fname = "c:/temp/bubble.jpg";
//******************************************
// with JMP version 11
rc = if(host is(Windows) & JMP Version()=="11.0.0",
fs = File Size(fname);
);
//******************************************
// with R file.info {base}
// http://stat.ethz.ch/R-manual/R-devel/library/base/html/file.info.html
// returns a data frame with various file info, is a dir?, times, IDs, etc.;
R Init();
R Send(fname);
R submit("\[
df = file.info(fname);
]\");
fs = R get(df$size);
show(fs); // in KB;
R Term();
//******************************************
// or, the hard way
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa364955(v=vs.85).aspx
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa364957(v=vs.85).aspx
kernel32 = Load DLL( "kernel32" );
// use createfile to retrive a reference to a file, i.e. a file handle
kernel32 << DeclareFunction( "CreateFileA", Convention( STDCALL ), Alias( "CreateFile" ),
Arg( AnsiString( 256 ), "lpFileName" ),
Arg( Int32, "dwDesiredAccess" ),
Arg( Int32, "dwShareMode" ),
Arg( IntPtr, "lpSecurityAttributes" ),
Arg( Int32, "dwCreationDisposition" ),
Arg( Int32, "dwFlagsAndAttributes" ),
Arg( UIntPtr, "hTemplateFile" ),
Returns( Int32 )
);
open_existing = 3;
hFile = kernel32 << CreateFile( fname, 0, 0, 0, open_existing, 0, 0);
// GetFileSize requires file handle (from above)
kernel32 << DeclareFunction( "GetFileSizeEx", Convention( STDCALL ), Alias( "GetFileSizeEx" ),
Arg( Int32, "hFile" ),
Arg( Int32, "lpFileSize", update ),
Returns( Int32 )
);
fs = 0;
rc = kernel32 << GetFileSizeEx( hFile, fs );
show(fs);
// clean up
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms724211(v=vs.85).aspx
kernel32 << DeclareFunction( "CloseHandle", Convention( STDCALL ), Alias( "CloseHandle" ),
Arg( Int32, "hFile" ),
Returns( Int32 )
);
rc = kernel32 << CloseHandle( hFile );
kernel32 << Unload DLL();
Best regards,-Matt