VishalMistry
17th August 2015, 12:43
is there any function to check if a particular file exists or not ?
Pl guide.
Vishal
bhushanchanda
17th August 2015, 13:32
Hi,
Yes, there is function - file.stat()
Syntax:
function long file.stat (string file_name, ref long file_size [, ref long ctime] [, ref long mtime] [, ref long atime])
Description
This returns information about a specified file. It is a short version of the stat.info() function.
Arguments
string file_name The name of the file for which information is required.
ref long file_size The file size in bytes.
[ref long ctime] The time when the file status was last changed, as a number of seconds since 00:00:00 GMT, January 1, 1970.
[ref long mtime] The time when the file was last modified, as a number of seconds since 00:00:00 GMT, January 1, 1970.
[ref long atime] The time when the file data was last accessed, as a number of seconds since 00:00:00 GMT, January 1, 1970.
Return values
0 File exists.
<>0 Operating system error code.
You can also use seq.open() and check the return code. If its >= 1 then file exists, else it doesn't exists/have some problem opening it up.
mark_h
17th August 2015, 17:08
I also use this a lot - before uploading the file to our UNIX servers for processing in 4c4. :)
| Open PC file to make sure it exists.
inputfile = seq.open.local(input.file,"r",0)
if(inputfile<0) then
file_err(inputfile)
return(true)
endif
seq.close.local(inputfile)
rc = client2server(input.file,temp.file,0)