diff options
author | Pixel <Pixel> | 2001-09-20 23:27:01 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2001-09-20 23:27:01 +0000 |
commit | 8346d0774d2d1e076038db27f65f1d082a460f16 (patch) | |
tree | 132f84cf1ef45d5006a2b1d52d4d40b1e8e51abc /lib/Output.cc |
Initial revision
Diffstat (limited to 'lib/Output.cc')
-rw-r--r-- | lib/Output.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Output.cc b/lib/Output.cc new file mode 100644 index 0000000..75bb437 --- /dev/null +++ b/lib/Output.cc @@ -0,0 +1,32 @@ +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#include "Output.h" +#include "Exceptions.h" +#include "config.h" + +Output::Output(String no, int trunc = 1) throw (IOGeneral) : + Handle(no.strlen() ? open(no.to_charp(), O_WRONLY | O_CREAT | (trunc ? O_TRUNC : O_APPEND)) : 1), + n(no) { + if (GetHandle() < 0) { + throw IOGeneral(String("Error opening file") + no + " for writing: " + strerror(errno)); + } +} + +bool Output::CanWrite() { + return 1; +} + +bool Output::CanRead() { + return 0; +} + +String Output::GetName() { + return n; +} + |