Saving

Saving – Saving your changes

Saving your changes

After modifying a fstab file, you will want to save your changes. The save() function does this.

Comments from the loaded file are not preserved when saving, and whitespace may change. This has no effect on the functionality of the fstab file, but you may lose helpful comments.

Save to the same file

This will save your changes back to the file you loaded, overwriting the old file.

<?php
require_once 'File/Fstab.php';
$fstab =& new File_Fstab();
$floppy =& new File_Fstab_Entry();
$floppy->fsType 'vfat';
$floppy->device '/dev/fd0';
$floppy->mountPoint '/floppy';
$fstab->addEntry($floppy);
$res $fstab->save();
if (
PEAR::isError($res)) {
    die(
$res->getMessage());
}
?>

Save to a different file

This will save your changes to a different file than the one you originally loaded.

<?php
require_once 'File/Fstab.php';
$fstab =& new File_Fstab();
$floppy =& new File_Fstab_Entry();
$floppy->fsType 'vfat';
$floppy->device '/dev/fd0';
$floppy->mountPoint '/floppy';
$fstab->addEntry($floppy);
$res $fstab->save('/tmp/fstab.new');
if (
PEAR::isError($res)) {
    die(
$res->getMessage());
}
?>