summaryrefslogtreecommitdiff
path: root/boost/interprocess/detail/os_file_functions.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/interprocess/detail/os_file_functions.hpp')
-rw-r--r--boost/interprocess/detail/os_file_functions.hpp66
1 files changed, 33 insertions, 33 deletions
diff --git a/boost/interprocess/detail/os_file_functions.hpp b/boost/interprocess/detail/os_file_functions.hpp
index b680c57132..08decd9bc4 100644
--- a/boost/interprocess/detail/os_file_functions.hpp
+++ b/boost/interprocess/detail/os_file_functions.hpp
@@ -32,7 +32,7 @@
# include <cstdio>
# include <dirent.h>
# if 0
-# include <sys/file.h>
+# include <sys/file.h>
# endif
# else
# error Unknown platform
@@ -58,7 +58,7 @@ typedef enum { read_only = winapi::generic_read
, read_write = winapi::generic_read | winapi::generic_write
, copy_on_write
, read_private
- , invalid_mode = 0xffff
+ , invalid_mode = 0xffff
} mode_t;
typedef enum { file_begin = winapi::file_begin
@@ -96,28 +96,28 @@ inline const char *get_temporary_path()
inline file_handle_t create_new_file
(const char *name, mode_t mode, const permissions & perm = permissions(), bool temporary = false)
-{
+{
unsigned long attr = temporary ? winapi::file_attribute_temporary : 0;
return winapi::create_file
( name, (unsigned int)mode, winapi::create_new, attr
- , (winapi::interprocess_security_attributes*)perm.get_permissions());
+ , (winapi::interprocess_security_attributes*)perm.get_permissions());
}
inline file_handle_t create_or_open_file
(const char *name, mode_t mode, const permissions & perm = permissions(), bool temporary = false)
-{
+{
unsigned long attr = temporary ? winapi::file_attribute_temporary : 0;
return winapi::create_file
( name, (unsigned int)mode, winapi::open_always, attr
- , (winapi::interprocess_security_attributes*)perm.get_permissions());
+ , (winapi::interprocess_security_attributes*)perm.get_permissions());
}
inline file_handle_t open_existing_file
(const char *name, mode_t mode, bool temporary = false)
-{
+{
unsigned long attr = temporary ? winapi::file_attribute_temporary : 0;
return winapi::create_file
- (name, (unsigned int)mode, winapi::open_existing, attr, 0);
+ (name, (unsigned int)mode, winapi::open_existing, attr, 0);
}
inline bool delete_file(const char *name)
@@ -140,7 +140,7 @@ inline bool truncate_file (file_handle_t hnd, std::size_t size)
if(offset_t(size) > filesize){
if(!winapi::set_file_pointer_ex(hnd, filesize, 0, winapi::file_begin)){
return false;
- }
+ }
//We will write zeros in the end of the file
//since set_end_of_file does not guarantee this
for(std::size_t remaining = size - filesize, write_size = 0
@@ -177,7 +177,7 @@ inline bool get_file_pointer(file_handle_t hnd, offset_t &off)
{ return winapi::set_file_pointer_ex(hnd, 0, &off, winapi::file_current); }
inline bool write_file(file_handle_t hnd, const void *data, std::size_t numdata)
-{
+{
unsigned long written;
return 0 != winapi::write_file(hnd, data, (unsigned long)numdata, &written, 0);
}
@@ -189,9 +189,9 @@ inline bool close_file(file_handle_t hnd)
{ return 0 != winapi::close_handle(hnd); }
inline bool acquire_file_lock(file_handle_t hnd)
-{
+{
static winapi::interprocess_overlapped overlapped;
- const unsigned long len = 0xffffffff;
+ const unsigned long len = ~((unsigned long)(0u));
// winapi::interprocess_overlapped overlapped;
// std::memset(&overlapped, 0, sizeof(overlapped));
return winapi::lock_file_ex
@@ -199,44 +199,44 @@ inline bool acquire_file_lock(file_handle_t hnd)
}
inline bool try_acquire_file_lock(file_handle_t hnd, bool &acquired)
-{
- const unsigned long len = 0xffffffff;
+{
+ const unsigned long len = ~((unsigned long)(0u));
winapi::interprocess_overlapped overlapped;
std::memset(&overlapped, 0, sizeof(overlapped));
if(!winapi::lock_file_ex
- (hnd, winapi::lockfile_exclusive_lock | winapi::lockfile_fail_immediately,
+ (hnd, winapi::lockfile_exclusive_lock | winapi::lockfile_fail_immediately,
0, len, len, &overlapped)){
- return winapi::get_last_error() == winapi::error_lock_violation ?
+ return winapi::get_last_error() == winapi::error_lock_violation ?
acquired = false, true : false;
-
+
}
return (acquired = true);
}
inline bool release_file_lock(file_handle_t hnd)
-{
- const unsigned long len = 0xffffffff;
+{
+ const unsigned long len = ~((unsigned long)(0u));
winapi::interprocess_overlapped overlapped;
std::memset(&overlapped, 0, sizeof(overlapped));
return winapi::unlock_file_ex(hnd, 0, len, len, &overlapped);
}
inline bool acquire_file_lock_sharable(file_handle_t hnd)
-{
- const unsigned long len = 0xffffffff;
+{
+ const unsigned long len = ~((unsigned long)(0u));
winapi::interprocess_overlapped overlapped;
std::memset(&overlapped, 0, sizeof(overlapped));
return winapi::lock_file_ex(hnd, 0, 0, len, len, &overlapped);
}
inline bool try_acquire_file_lock_sharable(file_handle_t hnd, bool &acquired)
-{
- const unsigned long len = 0xffffffff;
+{
+ const unsigned long len = ~((unsigned long)(0u));
winapi::interprocess_overlapped overlapped;
std::memset(&overlapped, 0, sizeof(overlapped));
if(!winapi::lock_file_ex
(hnd, winapi::lockfile_fail_immediately, 0, len, len, &overlapped)){
- return winapi::get_last_error() == winapi::error_lock_violation ?
+ return winapi::get_last_error() == winapi::error_lock_violation ?
acquired = false, true : false;
}
return (acquired = true);
@@ -367,7 +367,7 @@ typedef enum { read_only = O_RDONLY
, read_write = O_RDWR
, copy_on_write
, read_private
- , invalid_mode = 0xffff
+ , invalid_mode = 0xffff
} mode_t;
typedef enum { file_begin = SEEK_SET
@@ -406,7 +406,7 @@ inline const char *get_temporary_path()
inline file_handle_t create_new_file
(const char *name, mode_t mode, const permissions & perm = permissions(), bool temporary = false)
-{
+{
(void)temporary;
int ret = ::open(name, ((int)mode) | O_EXCL | O_CREAT, perm.get_permissions());
if(ret >= 0){
@@ -439,7 +439,7 @@ inline file_handle_t create_or_open_file
inline file_handle_t open_existing_file
(const char *name, mode_t mode, bool temporary = false)
-{
+{
(void)temporary;
return ::open(name, (int)mode);
}
@@ -459,7 +459,7 @@ inline bool truncate_file (file_handle_t hnd, std::size_t size)
}
inline bool get_file_size(file_handle_t hnd, offset_t &size)
-{
+{
struct stat data;
bool ret = 0 == ::fstat(hnd, &data);
if(ret){
@@ -472,7 +472,7 @@ inline bool set_file_pointer(file_handle_t hnd, offset_t off, file_pos_t pos)
{ return ((off_t)(-1)) != ::lseek(hnd, off, (int)pos); }
inline bool get_file_pointer(file_handle_t hnd, offset_t &off)
-{
+{
off = ::lseek(hnd, 0, SEEK_CUR);
return off != ((off_t)-1);
}
@@ -522,7 +522,7 @@ inline bool release_file_lock(file_handle_t hnd)
}
inline bool acquire_file_lock_sharable(file_handle_t hnd)
-{
+{
struct ::flock lock;
lock.l_type = F_RDLCK;
lock.l_whence = SEEK_SET;
@@ -532,7 +532,7 @@ inline bool acquire_file_lock_sharable(file_handle_t hnd)
}
inline bool try_acquire_file_lock_sharable(file_handle_t hnd, bool &acquired)
-{
+{
struct flock lock;
lock.l_type = F_RDLCK;
lock.l_whence = SEEK_SET;
@@ -540,7 +540,7 @@ inline bool try_acquire_file_lock_sharable(file_handle_t hnd, bool &acquired)
lock.l_len = 0;
int ret = ::fcntl(hnd, F_SETLK, &lock);
if(ret == -1){
- return (errno == EAGAIN || errno == EACCES) ?
+ return (errno == EAGAIN || errno == EACCES) ?
acquired = false, true : false;
}
return (acquired = true);
@@ -601,7 +601,7 @@ inline bool delete_subdirectories_recursive
|| (de->d_name[1] == '.' && de->d_name[2] == '\0' )) ){
continue;
}
- if(dont_delete_this && std::strcmp(dont_delete_this, de->d_name) == 0){
+ if(dont_delete_this && std::strcmp(dont_delete_this, de->d_name) == 0){
continue;
}
fn = refcstrRootDirectory;