Logo Search packages:      
Sourcecode: yapet version File versions  Download package

File::File ( const std::string &  fn,
const Key key,
bool  create = false,
bool  secure = true 
) throw (YAPETException)

Constructor.

Opens the file specified. Optionally creates the file if it does not exist and create is set true.

When opening an existing file, the key provided is validated. When creating a new file, the key is used to encrypt the header.

The file opened or created will stay open as long as the instance of this class exists. There is no method for closing the file. Only the destructor closes the file.

Parameters:
fn string holding the file name
key the key used for verification or encrypting the file header
create flag indicating whether the file should be created (true) or just opened (false). Be aware that passing true to this flag always causes the file to be created. Even if it already exists. Existing files will be truncated and the data stored will be lost.
secure if true, the functions checks whether or not the file permissions are secure. If false, file permissions are not checked for security. When creating a file and the value is true, the file is created using secure file permissions meaning only the owner has write and read access. Else, the owner has read and write access, the group and world has read access.

Definition at line 657 of file file.cc.

References initFile(), isempty(), openCreate(), openNoCreate(), and validateKey().

Referenced by setNewKey().

                          : filename(fn), usefsecurity(secure) {
    if (create)
      openCreate();
    else
      openNoCreate();

    if (isempty()) {
      initFile(key);
    } else {
      validateKey(key);
    }
}


Generated by  Doxygen 1.6.0   Back to index