FileTools[Compressed] - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

FileTools[Compressed]

  

ReadFile

  

read an entire compressed file

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

ReadFile(filename, outputtype, opts)

Parameters

filename

-

string or string:string

outputtype

-

(optional) either string, ByteArray, or 'Array'(m,n,hwdatatype)

opts

-

(optional) options as specified below

Options

• 

format : bzip2, zip, or gzip ; specify the input format explicitly

Description

• 

ReadFile is an all-in-one command to open a file, read and decompress its data, and close the file.

• 

If the given file is in zip format, and an in-zip name is not specified (using inzipname in zipfilename), then the first member of the zip archive is read.

• 

If the second parameter, outputtype, is string then the contents of the file are returned as a string.

• 

If the outputtype is not specified and the in-zip file name ends in ".m", then the contents of the zip file will be parsed as if they were in Maple's internal object format.

• 

If the outputtype is not specified and the in-zip file name ends in ".mpl", then the contents of the zip file will be parsed as if they were a single Maple-syntax text command.

• 

If outputtype is Array, then m and n are integers specifying the dimensions of the Array. The dimensions are optional, and one or more can be set. The hwdatatype indicates one of the integer[], float[], or complex[] datatype variations accepted by the 'datatype' option of the Array command.

• 

If outputtype is set to bytes or does not match any of the above criteria then an Array of datatype integer[1] is returned.

Examples

Read from a file in gzip format.

fileFileToolsTemporaryFilenameFileToolsJoinPathFileToolsTemporaryDirectory,GZtest-

file/usr/local/repository/tmp/mpldoc_slot0/mpldoc1/GZtest-yYoYxV9R

(1)

FileToolsCompressedWriteFilefile,This is a test

14

(2)

FileToolsCompressedReadFilefile,string

This is a test

(3)

FileToolsCompressedWriteFilefile,Array1..50,0,datatype=integer1

50

(4)

FileToolsCompressedReadFilefile

00000000000000000000000000000000000000000000000000

(5)

FileToolsRemovefile

Read from a file in zip format.

zipfileFileToolsTemporaryFilenamecatFileToolsTemporaryDirectory,kerneloptsdirsep,GZtest-,.zip

zipfile/usr/local/repository/tmp/mpldoc_slot0/mpldoc1/GZtest-bx70dpPu.zip

(6)

FileTools[Compressed][WriteFile]("first" in zipfile, "one");

3

(7)

FileTools[Compressed][WriteFile]("second" in zipfile, Array(1..50, 0, datatype=integer[1]));

50

(8)

FileToolsCompressedContentszipfile

first,second

(9)

FileToolsCompressedReadFilezipfile,string

one

(10)

FileTools[Compressed][ReadFile]("second" in zipfile);

00000000000000000000000000000000000000000000000000

(11)

FileToolsRemovezipfile

Compatibility

• 

The FileTools[Compressed][ReadFile] command was introduced in Maple 16.

• 

For more information on Maple 16 changes, see Updates in Maple 16.

See Also

FileTools[Compressed]

FileTools[Compressed][WriteFile]

FileTools[Remove]

StringTools[FromByteArray]