open a compressed file for reading or writing - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Input and Output : File Manipulation : FileTools : FileTools/Compressed/Open

FileTools[Compressed][Open] - open a compressed file for reading or writing

Calling Sequence

Open(filename, options)

Parameters

filename

-

string

options

-

(optional) argument(s) of the form option=value where option is one of mode, append, format, or gzipopts

Description

• 

The Open command opens a file to be read or written in gzip or zip format. It returns an integer file descriptor that can be passed to most of the commands in the subpackage FileTools[Compressed].

• 

If filename is the name of an existing file, the file is opened for reading unless the append option is passed or the option mode is set to WRITE.  If mode=WRITE is given, filename will be overwritten unless the option append is also given.

• 

If filename is not an existing file, then it will be opened for writing.

• 

The format will be implicitly determined by the filename -- if the suffix is ".zip", ".ZIP" or of the form "subfile" in "zipfile", then the system will assume the file is in zip format.  Otherwise it will be opened as if it were in gzip format.  The format=gzip or format=zip option can be used to force the recognition of a specified format.

Examples

file := FileTools[TemporaryFilename](cat(FileTools[TemporaryDirectory](),kernelopts(dirsep),"GZtest-"));

file:=/mnt/tmpfs/mpldoc_slot1/mpldoc1/GZtest-yYoYxV9R

(1)

fd := FileTools[Compressed][Open](file);

fd:=18102608

(2)

FileTools[Compressed][Close](fd);

0

(3)

FileTools[Compressed][Open](file);

17468768

(4)

FileTools[Compressed][Open](file);

Error, (in FileTools:-Compressed:-Open) file /mnt/tmpfs/mpldoc_slot1/mpldoc1/GZtest-yYoYxV9R is already open

FileTools[Compressed][Close](file);

0

(5)

See Also

FileTools[Compressed], FileTools[Compressed][Close], FileTools[Compressed][Read], FileTools[Compressed][Write], FileTools[Remove]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam