text: //stat.cpp
  
  // Copyright Querysoft Limited 2015
  //
  // Permission is hereby granted, free of charge, to any person or organization
  // obtaining a copy of the software and accompanying documentation covered by
  // this license (the "Software") to use, reproduce, display, distribute,
  // execute, and transmit the Software, and to prepare derivative works of the
  // Software, and to permit third-parties to whom the Software is furnished to
  // do so, all subject to the following:
  //
  // The copyright notices in the Software and this entire statement, including
  // the above license grant, this restriction and the following disclaimer,
  // must be included in all copies of the Software, in whole or in part, and
  // all derivative works of the Software, unless such copies or derivative
  // works are solely in the form of machine-executable object code generated by
  // a source language processor.
  //
  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
  // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
  // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
  // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  // DEALINGS IN THE SOFTWARE.
  
  //Generic stat implementation
  //An exported standard C interface which forwards calls to the matching C++ implementaion for the platform
  
  #include "CQOR/CQORPolicy.h"
  #include <sys/stat.h>
  #include <errno.h>
  #include "SystemQOR.h"
  #include QOR_SYS_PLATFORMSYSHEADER(stat.h)
  #include "CodeQOR/Tracing/FunctionContextBase.h"
  #include "CodeQOR/ErrorSystem/Error.h"
  #include "CQOR.h"
  
  //--------------------------------------------------------------------------------
  namespace
  {
  	nsPlatform::Cstat sys_stat;
  }//anonymous
  
  __QCMP_STARTLINKAGE_C
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int chmod( const char* path, ::mode_t mode )
  {
      __QCS_FCONTEXT( "chmod" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.chmod( path, mode );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int fchmod( int fildes, ::mode_t mode )
  {
      __QCS_FCONTEXT( "fchmod" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.fchmod( fildes, mode );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int fchmodat( int fd, const char* path, ::mode_t mode, int flag )
  {
      __QCS_FCONTEXT( "fchmodat" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.fchmodat( fd, path, mode, flag );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int fstat( int fildes, ::stat* buf )
  {
      __QCS_FCONTEXT( "fstat" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.fstat( fildes, buf );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int fstatat( int fd, const char* __QCMP_RESTRICT path, ::stat* __QCMP_RESTRICT buf, int flag )
  {
      __QCS_FCONTEXT( "fstatat" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.fstatat( fd, path, buf, flag );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int futimens( int fd, const ::timespec times[ 2 ] )
  {
      __QCS_FCONTEXT( "futimens" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.futimens( fd, times );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int lstat( const char* __QCMP_RESTRICT path, ::stat* __QCMP_RESTRICT buf )
  {
      __QCS_FCONTEXT( "lstat" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.lstat( path, buf );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int mkdir( const char* path, ::mode_t mode )
  {
      __QCS_FCONTEXT( "mkdir" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.mkdir( path, mode );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int mkdirat( int fd, const char* path, ::mode_t mode )
  {
      __QCS_FCONTEXT( "mkdirat" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.mkdirat( fd, path, mode );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int mkfifo( const char* path, ::mode_t mode )
  {
      __QCS_FCONTEXT( "mkfifo" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.mkfifo( path, mode );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int mkfifoat( int fd, const char* path, ::mode_t mode )
  {
      __QCS_FCONTEXT( "mkfifoat" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.mkfifoat( fd, path, mode );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int mknod( const char* path, ::mode_t mode, ::dev_t dev )
  {
      __QCS_FCONTEXT( "mknod" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.mknod( path, mode, dev );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int mknodat( int fd, const char* path, ::mode_t mode, ::dev_t dev )
  {
      __QCS_FCONTEXT( "mknodat" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.mknodat( fd, path, mode, dev );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  __QCMP_ENDLINKAGE_C
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int _stat( const char* __QCMP_RESTRICT path, ::stat* __QCMP_RESTRICT buf )
  {
      __QCS_FCONTEXT( "stat" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.stat( path, buf );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  __QCMP_STARTLINKAGE_C
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) ::mode_t umask( ::mode_t cmask )
  {
      __QCS_FCONTEXT( "umask" );
      mode_t Result = 0;
      __QCS_PROTECT
      {
          Result = sys_stat.umask( cmask );
      }__QCS_ENDPROTECT
      return Result;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int utimensat( int fd, const char* path, const ::timespec times[ 2 ], int flag )
  {
      __QCS_FCONTEXT( "" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat.utimensat( fd, path, times, flag );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int _umask( int pmode )
  {
      __QCS_FCONTEXT( "_umask" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat._umask( pmode );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) ::errno_t _umask_s( int mode, int* pOldMode )
  {
      __QCS_FCONTEXT( "_umask_s" );
      errno_t Result = 0;
      __QCS_PROTECT
      {
          Result = sys_stat._umask_s( mode, pOldMode );
      }__QCS_ENDPROTECT
      return Result;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int _stat( const char* path, _sstat* buffer )
  {
      __QCS_FCONTEXT( "_stat" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat._stat( path, buffer );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int _stat64( const char* path, __sstat64* buffer )
  {
      __QCS_FCONTEXT( "_stat64" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat._stat64( path, buffer );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  //--------------------------------------------------------------------------------
  __QOR_INTERFACE( __CQOR ) int _stati64( const char* path, _sstati64* buffer )
  {
      __QCS_FCONTEXT( "_stati64" );
      int iResult = 0;
      __QCS_PROTECT
      {
          iResult = sys_stat._stati64( path, buffer );
      }__QCS_ENDPROTECT
      return iResult;
  }
  
  __QCMP_ENDLINKAGE_C
  