name: File

synopsis:

g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_system.a

#include <File.h>
File(STREAM stream = DEF_STREAM);
boolean open(const SysString& filename, MODE mode = READ_ONLY);
boolean put(const SysString& str);
boolean close();
quick start:

File out(File::ERROR);
File foo_wo;
SysString temp_file;

Integral::makeTemp(temp_file);

if (!foo_wo.open(temp_file, File::WRITE_ONLY)) {
  Console::put(L"Error in open");
}

SysString str1(L"testing output\n");
out.put(str1);

foo_wo.put(str1);

foo_wo.close();

File::remove(temp_file);
description:

File: a general purpose file pointer. this class abstracts file manipulations, which are operating system specific, and provides a general interface that all classes should use to access files.

An important feature of this class is that a polling strategy for opening files is built into the class. When a file open fails, it is possible that the file exists, but the network file system for the computer is in error. This happens often in unix when dealing with files using the network file system. An effective solution is simply to wait a specified time, and try again. More often than not, the next open will succeed. Since all file I/O is centralized through this class, this feature is automatically available to all isip classes.

This class also has the ability to read from stdin (Standard Input) and write to stdout (Standard Output). There are two ways this can be done. The first is to pass `IN' or `OUT' to the constructor in order to read from stdin or write to stdout, respectively ( for example: File stdinFile(File::IN); ). The second is to use the `open' method, and pass a SysString type "-" as the first argument instead of a file name. See below for an example.

When reading from stdin, the input is buffered into a temporary file which is removed when the file object is closed.

dependencies:

public constants:

error codes:

protected data:

required public methods:

class-specific public methods:

private methods:

example 1:

example 2:

notes: