aboutsummaryrefslogtreecommitdiff
path: root/src/stable/file.cpp
diff options
context:
space:
mode:
authorMike Buland <mbuland@penny-arcade.com>2018-05-25 14:17:20 -0700
committerMike Buland <mbuland@penny-arcade.com>2018-05-25 14:17:20 -0700
commit9bcbc8f919fc1c779d3b9c649dcbe3606fdbed32 (patch)
tree3f3983791f54b0b6112f7a9a887739c52d0504ea /src/stable/file.cpp
parentf31d308827f848fdcd8ad61b89513f3c20b34e20 (diff)
downloadlibbu++-9bcbc8f919fc1c779d3b9c649dcbe3606fdbed32.tar.gz
libbu++-9bcbc8f919fc1c779d3b9c649dcbe3606fdbed32.tar.bz2
libbu++-9bcbc8f919fc1c779d3b9c649dcbe3606fdbed32.tar.xz
libbu++-9bcbc8f919fc1c779d3b9c649dcbe3606fdbed32.zip
Added locking support to Bu::File.
Diffstat (limited to 'src/stable/file.cpp')
-rw-r--r--src/stable/file.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/stable/file.cpp b/src/stable/file.cpp
index 35933f1..a15f394 100644
--- a/src/stable/file.cpp
+++ b/src/stable/file.cpp
@@ -9,6 +9,7 @@
9#include <errno.h> 9#include <errno.h>
10#include <sys/types.h> 10#include <sys/types.h>
11#include <sys/stat.h> 11#include <sys/stat.h>
12#include <sys/file.h>
12#include <fcntl.h> 13#include <fcntl.h>
13#include <unistd.h> 14#include <unistd.h>
14#include <time.h> 15#include <time.h>
@@ -200,6 +201,21 @@ void Bu::File::setBlocking( bool bBlocking )
200#endif 201#endif
201} 202}
202 203
204bool Bu::File::canLock() const
205{
206 return true;
207}
208
209void Bu::File::lock( bool bExclusive )
210{
211 ::flock( fd, bExclusive?LOCK_EX:LOCK_SH );
212}
213
214void Bu::File::unlock()
215{
216 ::flock( fd, LOCK_UN );
217}
218
203Bu::File Bu::File::tempFile( Bu::String &sName ) 219Bu::File Bu::File::tempFile( Bu::String &sName )
204{ 220{
205 int iXes; 221 int iXes;