WvStreams
wvatomicfile.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2005 Net Integration Technologies, Inc.
4  *
5  * A simple class to access filesystem files using WvStreams.
6  */
7 #ifndef __WVATOMFILE_H
8 #define __WVATOMFILE_H
9 
10 #include "wvfile.h"
11 
21 class WvAtomicFile : public WvFile
22 {
23 private:
24  WvString atomic_file;
25  WvString tmp_file;
26 
27 public:
28  WvAtomicFile(WvStringParm filename, int flags = O_TRUNC | O_CREAT,
29  mode_t create_mode = 0666);
30  ~WvAtomicFile();
31 
32  bool open(WvStringParm filename, int flags = O_TRUNC | O_CREAT,
33  mode_t create_mode = 0666);
34  void close();
35 
36  // Like chmod(2), does *not* respect umask
37  bool chmod(mode_t mode);
38 
39  bool chown(uid_t owner, gid_t group);
40 
41 public:
42  const char *wstype() const { return "WvAtomicFile"; }
43 };
44 
45 #endif // __WVATOMFILE_H
WvAtomicFile::close
void close()
Closes the file descriptors.
Definition: wvatomicfile.cc:70
WvFile
WvFile implements a stream connected to a file or Unix device.
Definition: wvfile.h:28
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
group
Definition: argp-parse.c:204
WvAtomicFile
WvAtomicFile implements a simple extension to wvfile to allow for atomic file creation.
Definition: wvatomicfile.h:21