WvStreams
|
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2005 Net Integration Technologies, Inc. 00004 * 00005 * A simple class to access filesystem files using WvStreams. 00006 */ 00007 #ifndef __WVATOMFILE_H 00008 #define __WVATOMFILE_H 00009 00010 #include "wvfile.h" 00011 00021 class WvAtomicFile : public WvFile 00022 { 00023 private: 00024 WvString atomic_file; 00025 WvString tmp_file; 00026 00027 public: 00028 WvAtomicFile(WvStringParm filename, int flags = O_TRUNC | O_CREAT, 00029 mode_t create_mode = 0666); 00030 ~WvAtomicFile(); 00031 00032 bool open(WvStringParm filename, int flags = O_TRUNC | O_CREAT, 00033 mode_t create_mode = 0666); 00034 void close(); 00035 00036 // Like chmod(2), does *not* respect umask 00037 bool chmod(mode_t mode); 00038 00039 bool chown(uid_t owner, gid_t group); 00040 00041 public: 00042 const char *wstype() const { return "WvAtomicFile"; } 00043 }; 00044 00045 #endif // __WVATOMFILE_H