wvdbusserver: implement NameHasOwner request.
[wvstreams.git] / include / wvatomicfile.h
blob366218c176c174c7a8b09285948812ccce00035f
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2005 Net Integration Technologies, Inc.
5 * A simple class to access filesystem files using WvStreams.
6 */
7 #ifndef __WVATOMFILE_H
8 #define __WVATOMFILE_H
10 #include "wvfile.h"
12 /**
13 * WvAtomicFile implements a simple extension to wvfile to allow for
14 * atomic file creation. Files normally can be created and written
15 * to, however, in the event of a kernel panic the file can be left in
16 * an unusable state.
18 * A WvAtomicFile is atomically created on file close
21 class WvAtomicFile : public WvFile
23 private:
24 WvString atomic_file;
25 WvString tmp_file;
27 public:
28 WvAtomicFile(WvStringParm filename, int flags = O_TRUNC | O_CREAT,
29 mode_t create_mode = 0666);
30 ~WvAtomicFile();
32 bool open(WvStringParm filename, int flags = O_TRUNC | O_CREAT,
33 mode_t create_mode = 0666);
34 void close();
36 // Like chmod(2), does *not* respect umask
37 bool chmod(mode_t mode);
39 bool chown(uid_t owner, gid_t group);
41 public:
42 const char *wstype() const { return "WvAtomicFile"; }
45 #endif // __WVATOMFILE_H