Merge pull request #7 from ikatson/osx-after-review

Make zbackup compile on OS X.
master
Konstantin Isakov 2013-07-22 13:39:18 -07:00
commit ba00c58c85
4 changed files with 24 additions and 5 deletions

View File

@ -29,9 +29,10 @@
using std::vector;
// 32-bit specific hash function for unsigned long long which is what uint64_t
// is on 32-bit platforms
#if SIZE_MAX == UINT32_MAX
// 32-bit specific hash function for unsigned long long which is what
// uint64_t is on 32-bit platforms. Also, on Mac, uint64_t is defined
// as 'unsigned long long'.
#if (SIZE_MAX == UINT32_MAX || defined __APPLE__)
namespace __gnu_cxx
{
template<>

5
dir.cc
View File

@ -96,8 +96,13 @@ bool Listing::getNext( Entry & result )
if ( !entryPtr )
return false;
#ifndef __APPLE__
if ( fstatat( dirfd( dir ), entry.d_name, &entryStats,
AT_SYMLINK_NOFOLLOW ) != 0 )
#else
if ( lstat( addPath( dirName, entry.d_name ).c_str(),
&entryStats ) != 0)
#endif
throw exCantList( dirName );
bool isDir = S_ISDIR( entryStats.st_mode );

View File

@ -6,7 +6,11 @@
#include <stdint.h>
#include <arpa/inet.h>
#ifdef __APPLE__
#include <machine/endian.h>
#else
#include <endian.h>
#endif
#if __BYTE_ORDER != __LITTLE_ENDIAN
#error Please add support for architectures different from little-endian.

View File

@ -12,12 +12,21 @@
#include "check.hh"
#include "unbuffered_file.hh"
#ifdef __APPLE__
#define lseek64 lseek
#endif
UnbufferedFile::UnbufferedFile( char const * fileName, Mode mode )
throw( exCantOpen )
{
int flags = O_LARGEFILE |
( mode == WriteOnly ? ( O_WRONLY | O_CREAT | O_TRUNC ) :
int flags = ( mode == WriteOnly ? ( O_WRONLY | O_CREAT | O_TRUNC ) :
O_RDONLY );
#ifndef __APPLE__
flags |= O_LARGEFILE;
#endif
fd = open( fileName, flags, 0666 );
if ( fd < 0 )
throw exCantOpen( fileName );