FreeRDP
winpr/libwinpr/file/file.c File Reference
#include <winpr/wtypes.h>
#include <winpr/crt.h>
#include <winpr/file.h>
#include "../log.h"
#include <winpr/wlog.h>
#include <winpr/string.h>
#include "file.h"
#include <errno.h>
#include <fcntl.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/statvfs.h>

Macros

#define TAG   WINPR_TAG("file")
 
#define STATVFS   statvfs
 

Functions

static BOOL FileIsHandled (HANDLE handle)
 
static int FileGetFd (HANDLE handle)
 
static BOOL FileCloseHandle (HANDLE handle)
 
static BOOL FileSetEndOfFile (HANDLE hFile)
 
static DWORD FileSetFilePointer (HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
 
static BOOL FileSetFilePointerEx (HANDLE hFile, LARGE_INTEGER liDistanceToMove, PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod)
 
static BOOL FileRead (PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
 
static BOOL FileWrite (PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
 
static DWORD FileGetFileSize (HANDLE Object, LPDWORD lpFileSizeHigh)
 
static BOOL FileLockFileEx (HANDLE hFile, DWORD dwFlags, DWORD dwReserved, DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, LPOVERLAPPED lpOverlapped)
 
static BOOL FileUnlockFile (HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh)
 
static BOOL FileUnlockFileEx (HANDLE hFile, DWORD dwReserved, DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped)
 
static UINT64 FileTimeToUS (const FILETIME *ft)
 
static BOOL FileSetFileTime (HANDLE hFile, const FILETIME *lpCreationTime, const FILETIME *lpLastAccessTime, const FILETIME *lpLastWriteTime)
 
static const char * FileGetMode (DWORD dwDesiredAccess, DWORD dwCreationDisposition, BOOL *create)
 
UINT32 map_posix_err (int fs_errno)
 
static HANDLE FileCreateFileA (LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
 
BOOL IsFileDevice (LPCTSTR lpDeviceName)
 
HANDLE_CREATORGetFileHandleCreator (void)
 
static WINPR_FILE * FileHandle_New (FILE *fp)
 
HANDLE GetStdHandle (DWORD nStdHandle)
 
BOOL SetStdHandle (DWORD nStdHandle, HANDLE hHandle)
 
BOOL SetStdHandleEx (DWORD dwStdHandle, HANDLE hNewHandle, HANDLE *phOldHandle)
 
BOOL GetDiskFreeSpaceA (LPCSTR lpRootPathName, LPDWORD lpSectorsPerCluster, LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters)
 
BOOL GetDiskFreeSpaceW (LPCWSTR lpwRootPathName, LPDWORD lpSectorsPerCluster, LPDWORD lpBytesPerSector, LPDWORD lpNumberOfFreeClusters, LPDWORD lpTotalNumberOfClusters)
 
BOOL ValidFileNameComponent (LPCWSTR lpFileName)
 
HANDLE GetFileHandleForFileDescriptor (int fd)
 

Variables

static HANDLE_OPS fileOps
 
static HANDLE_OPS shmOps
 
HANDLE_CREATOR _FileHandleCreator
 

Macro Definition Documentation

#define STATVFS   statvfs
#define TAG   WINPR_TAG("file")

WinPR: Windows Portable Runtime File Functions

Copyright 2015 Thincast Technologies GmbH Copyright 2015 Bernhard Miklautz bernh.nosp@m.ard..nosp@m.mikla.nosp@m.utz@.nosp@m.thinc.nosp@m.ast..nosp@m.com Copyright 2016 David PHAM-VAN d.pha.nosp@m.mvan.nosp@m.@inuv.nosp@m.ika..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

static BOOL FileCloseHandle ( HANDLE  handle)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static HANDLE FileCreateFileA ( LPCSTR  lpFileName,
DWORD  dwDesiredAccess,
DWORD  dwShareMode,
LPSECURITY_ATTRIBUTES  lpSecurityAttributes,
DWORD  dwCreationDisposition,
DWORD  dwFlagsAndAttributes,
HANDLE  hTemplateFile 
)
static

Here is the call graph for this function:

static int FileGetFd ( HANDLE  handle)
static

Here is the call graph for this function:

static DWORD FileGetFileSize ( HANDLE  Object,
LPDWORD  lpFileSizeHigh 
)
static

Here is the call graph for this function:

static const char* FileGetMode ( DWORD  dwDesiredAccess,
DWORD  dwCreationDisposition,
BOOL *  create 
)
static

Here is the caller graph for this function:

static WINPR_FILE* FileHandle_New ( FILE *  fp)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL FileIsHandled ( HANDLE  handle)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL FileLockFileEx ( HANDLE  hFile,
DWORD  dwFlags,
DWORD  dwReserved,
DWORD  nNumberOfBytesToLockLow,
DWORD  nNumberOfBytesToLockHigh,
LPOVERLAPPED  lpOverlapped 
)
static

Here is the call graph for this function:

static BOOL FileRead ( PVOID  Object,
LPVOID  lpBuffer,
DWORD  nNumberOfBytesToRead,
LPDWORD  lpNumberOfBytesRead,
LPOVERLAPPED  lpOverlapped 
)
static

Here is the call graph for this function:

static BOOL FileSetEndOfFile ( HANDLE  hFile)
static

Here is the call graph for this function:

static DWORD FileSetFilePointer ( HANDLE  hFile,
LONG  lDistanceToMove,
PLONG  lpDistanceToMoveHigh,
DWORD  dwMoveMethod 
)
static
static BOOL FileSetFilePointerEx ( HANDLE  hFile,
LARGE_INTEGER  liDistanceToMove,
PLARGE_INTEGER  lpNewFilePointer,
DWORD  dwMoveMethod 
)
static
static BOOL FileSetFileTime ( HANDLE  hFile,
const FILETIME *  lpCreationTime,
const FILETIME *  lpLastAccessTime,
const FILETIME *  lpLastWriteTime 
)
static

Here is the call graph for this function:

static UINT64 FileTimeToUS ( const FILETIME *  ft)
static

Here is the caller graph for this function:

static BOOL FileUnlockFile ( HANDLE  hFile,
DWORD  dwFileOffsetLow,
DWORD  dwFileOffsetHigh,
DWORD  nNumberOfBytesToUnlockLow,
DWORD  nNumberOfBytesToUnlockHigh 
)
static
static BOOL FileUnlockFileEx ( HANDLE  hFile,
DWORD  dwReserved,
DWORD  nNumberOfBytesToUnlockLow,
DWORD  nNumberOfBytesToUnlockHigh,
LPOVERLAPPED  lpOverlapped 
)
static

Here is the call graph for this function:

static BOOL FileWrite ( PVOID  Object,
LPCVOID  lpBuffer,
DWORD  nNumberOfBytesToWrite,
LPDWORD  lpNumberOfBytesWritten,
LPOVERLAPPED  lpOverlapped 
)
static

Here is the call graph for this function:

BOOL GetDiskFreeSpaceA ( LPCSTR  lpRootPathName,
LPDWORD  lpSectorsPerCluster,
LPDWORD  lpBytesPerSector,
LPDWORD  lpNumberOfFreeClusters,
LPDWORD  lpTotalNumberOfClusters 
)

Here is the caller graph for this function:

BOOL GetDiskFreeSpaceW ( LPCWSTR  lpwRootPathName,
LPDWORD  lpSectorsPerCluster,
LPDWORD  lpBytesPerSector,
LPDWORD  lpNumberOfFreeClusters,
LPDWORD  lpTotalNumberOfClusters 
)

Here is the call graph for this function:

Here is the caller graph for this function:

HANDLE_CREATOR* GetFileHandleCreator ( void  )

Here is the caller graph for this function:

HANDLE GetFileHandleForFileDescriptor ( int  fd)

Here is the call graph for this function:

HANDLE GetStdHandle ( DWORD  nStdHandle)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL IsFileDevice ( LPCTSTR  lpDeviceName)
UINT32 map_posix_err ( int  fs_errno)

Here is the caller graph for this function:

BOOL SetStdHandle ( DWORD  nStdHandle,
HANDLE  hHandle 
)
BOOL SetStdHandleEx ( DWORD  dwStdHandle,
HANDLE  hNewHandle,
HANDLE *  phOldHandle 
)
BOOL ValidFileNameComponent ( LPCWSTR  lpFileName)

Check if a file name component is valid.

Some file names are not valid on Windows. See "Naming Files, Paths, and Namespaces": https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

HANDLE_CREATOR _FileHandleCreator
Initial value:
=
{
}
BOOL IsFileDevice(LPCTSTR lpDeviceName)
Definition: winpr/libwinpr/file/file.c:874
static HANDLE FileCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
Definition: winpr/libwinpr/file/file.c:718
HANDLE_OPS fileOps
static
Initial value:
= {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
}
static BOOL FileSetEndOfFile(HANDLE hFile)
Definition: winpr/libwinpr/file/file.c:105
static BOOL FileRead(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
Definition: winpr/libwinpr/file/file.c:207
static BOOL FileCloseHandle(HANDLE handle)
Definition: winpr/libwinpr/file/file.c:84
static BOOL FileSetFileTime(HANDLE hFile, const FILETIME *lpCreationTime, const FILETIME *lpLastAccessTime, const FILETIME *lpLastWriteTime)
Definition: winpr/libwinpr/file/file.c:494
static int FileGetFd(HANDLE handle)
Definition: winpr/libwinpr/file/file.c:74
static DWORD FileSetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: winpr/libwinpr/file/file.c:127
static DWORD FileGetFileSize(HANDLE Object, LPDWORD lpFileSizeHigh)
Definition: winpr/libwinpr/file/file.c:278
static BOOL FileUnlockFile(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh)
Definition: winpr/libwinpr/file/file.c:396
static BOOL FileIsHandled(HANDLE handle)
Definition: winpr/libwinpr/file/file.c:61
static BOOL FileLockFileEx(HANDLE hFile, DWORD dwFlags, DWORD dwReserved, DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, LPOVERLAPPED lpOverlapped)
Definition: winpr/libwinpr/file/file.c:326
if availableBytes return NULL
Definition: TPCircularBuffer.h:104
static BOOL FileSetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove, PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod)
Definition: winpr/libwinpr/file/file.c:171
static BOOL FileUnlockFileEx(HANDLE hFile, DWORD dwReserved, DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped)
Definition: winpr/libwinpr/file/file.c:437
static BOOL FileWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
Definition: winpr/libwinpr/file/file.c:248
HANDLE_OPS shmOps
static
Initial value:
= {
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
}
static BOOL FileRead(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
Definition: winpr/libwinpr/file/file.c:207
static BOOL FileCloseHandle(HANDLE handle)
Definition: winpr/libwinpr/file/file.c:84
static int FileGetFd(HANDLE handle)
Definition: winpr/libwinpr/file/file.c:74
static BOOL FileIsHandled(HANDLE handle)
Definition: winpr/libwinpr/file/file.c:61
if availableBytes return NULL
Definition: TPCircularBuffer.h:104
static BOOL FileWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
Definition: winpr/libwinpr/file/file.c:248