FreeRDP
generic.c File Reference
#include <winpr/crt.h>
#include <winpr/path.h>
#include <winpr/file.h>
#include "../log.h"
#include <assert.h>
#include <pthread.h>
#include <dirent.h>
#include <libgen.h>
#include <errno.h>
#include <sys/un.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/statvfs.h>
#include "../handle/handle.h"
#include "../pipe/pipe.h"
#include "file.h"

Macros

#define TAG   WINPR_TAG("file")
 
#define EPOCH_DIFF   11644473600LL
 
#define STAT_TIME_TO_FILETIME(_t)   (((UINT64)(_t) + EPOCH_DIFF) * 10000000LL)
 

Functions

HANDLE_CREATORGetNamedPipeClientHandleCreator (void)
 
static void _HandleCreatorsInit ()
 
HANDLE CreateFileA (LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
 
HANDLE CreateFileW (LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
 
BOOL DeleteFileA (LPCSTR lpFileName)
 
BOOL DeleteFileW (LPCWSTR lpFileName)
 
BOOL ReadFile (HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
 
BOOL ReadFileEx (HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPOVERLAPPED lpOverlapped, LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
 
BOOL ReadFileScatter (HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[], DWORD nNumberOfBytesToRead, LPDWORD lpReserved, LPOVERLAPPED lpOverlapped)
 
BOOL WriteFile (HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
 
BOOL WriteFileEx (HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPOVERLAPPED lpOverlapped, LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
 
BOOL WriteFileGather (HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[], DWORD nNumberOfBytesToWrite, LPDWORD lpReserved, LPOVERLAPPED lpOverlapped)
 
BOOL FlushFileBuffers (HANDLE hFile)
 
BOOL WINAPI GetFileAttributesExA (LPCSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
 
BOOL WINAPI GetFileAttributesExW (LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
 
DWORD WINAPI GetFileAttributesA (LPCSTR lpFileName)
 
DWORD WINAPI GetFileAttributesW (LPCWSTR lpFileName)
 
BOOL SetFileAttributesA (LPCSTR lpFileName, DWORD dwFileAttributes)
 
BOOL SetFileAttributesW (LPCWSTR lpFileName, DWORD dwFileAttributes)
 
BOOL SetEndOfFile (HANDLE hFile)
 
DWORD WINAPI GetFileSize (HANDLE hFile, LPDWORD lpFileSizeHigh)
 
DWORD SetFilePointer (HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
 
BOOL SetFilePointerEx (HANDLE hFile, LARGE_INTEGER liDistanceToMove, PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod)
 
BOOL LockFile (HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh)
 
BOOL LockFileEx (HANDLE hFile, DWORD dwFlags, DWORD dwReserved, DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh, LPOVERLAPPED lpOverlapped)
 
BOOL UnlockFile (HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh, DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh)
 
BOOL UnlockFileEx (HANDLE hFile, DWORD dwReserved, DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped)
 
BOOL WINAPI SetFileTime (HANDLE hFile, const FILETIME *lpCreationTime, const FILETIME *lpLastAccessTime, const FILETIME *lpLastWriteTime)
 
static BOOL FindDataFromStat (const char *path, const struct stat *fileStat, LPWIN32_FIND_DATAA lpFindFileData)
 
HANDLE FindFirstFileA (LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
 
static BOOL ConvertFindDataAToW (LPWIN32_FIND_DATAA lpFindFileDataA, LPWIN32_FIND_DATAW lpFindFileDataW)
 
HANDLE FindFirstFileW (LPCWSTR lpFileName, LPWIN32_FIND_DATAW lpFindFileData)
 
HANDLE FindFirstFileExA (LPCSTR lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, LPVOID lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, LPVOID lpSearchFilter, DWORD dwAdditionalFlags)
 
HANDLE FindFirstFileExW (LPCWSTR lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, LPVOID lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, LPVOID lpSearchFilter, DWORD dwAdditionalFlags)
 
BOOL FindNextFileA (HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData)
 
BOOL FindNextFileW (HANDLE hFindFile, LPWIN32_FIND_DATAW lpFindFileData)
 
BOOL FindClose (HANDLE hFindFile)
 
BOOL CreateDirectoryA (LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
 
BOOL CreateDirectoryW (LPCWSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
 
BOOL RemoveDirectoryA (LPCSTR lpPathName)
 
BOOL RemoveDirectoryW (LPCWSTR lpPathName)
 
BOOL MoveFileExA (LPCSTR lpExistingFileName, LPCSTR lpNewFileName, DWORD dwFlags)
 
BOOL MoveFileExW (LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName, DWORD dwFlags)
 
BOOL MoveFileA (LPCSTR lpExistingFileName, LPCSTR lpNewFileName)
 
BOOL MoveFileW (LPCWSTR lpExistingFileName, LPCWSTR lpNewFileName)
 
int UnixChangeFileMode (const char *filename, int flags)
 

Variables

static wArrayList * _HandleCreators
 
static pthread_once_t _HandleCreatorsInitialized = PTHREAD_ONCE_INIT
 

Macro Definition Documentation

#define EPOCH_DIFF   11644473600LL

api-ms-win-core-file-l1-2-0.dll:

CreateFileA CreateFileW CreateFile2 DeleteFileA DeleteFileW CreateDirectoryA CreateDirectoryW RemoveDirectoryA RemoveDirectoryW CompareFileTime DefineDosDeviceW DeleteVolumeMountPointW FileTimeToLocalFileTime LocalFileTimeToFileTime FindClose FindCloseChangeNotification FindFirstChangeNotificationA FindFirstChangeNotificationW FindFirstFileA FindFirstFileExA FindFirstFileExW FindFirstFileW FindFirstVolumeW FindNextChangeNotification FindNextFileA FindNextFileW FindNextVolumeW FindVolumeClose GetDiskFreeSpaceA GetDiskFreeSpaceExA GetDiskFreeSpaceExW GetDiskFreeSpaceW GetDriveTypeA GetDriveTypeW GetFileAttributesA GetFileAttributesExA GetFileAttributesExW GetFileAttributesW GetFileInformationByHandle GetFileSize GetFileSizeEx GetFileTime GetFileType GetFinalPathNameByHandleA GetFinalPathNameByHandleW GetFullPathNameA GetFullPathNameW GetLogicalDrives GetLogicalDriveStringsW GetLongPathNameA GetLongPathNameW GetShortPathNameW GetTempFileNameW GetTempPathW GetVolumeInformationByHandleW GetVolumeInformationW GetVolumeNameForVolumeMountPointW GetVolumePathNamesForVolumeNameW GetVolumePathNameW QueryDosDeviceW SetFileAttributesA SetFileAttributesW SetFileTime SetFileValidData SetFileInformationByHandle ReadFile ReadFileEx ReadFileScatter WriteFile WriteFileEx WriteFileGather FlushFileBuffers SetEndOfFile SetFilePointer SetFilePointerEx LockFile LockFileEx UnlockFile UnlockFileEx File System Behavior in the Microsoft Windows Environment: http://download.microsoft.com/download/4/3/8/43889780-8d45-4b2e-9d3a-c696a890309f/File%20System%20Behavior%20Overview.pdf Asynchronous I/O - The GNU C Library: http://www.gnu.org/software/libc/manual/html_node/Asynchronous-I_002fO.html aio.h - asynchronous input and output: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/aio.h.html Asynchronous I/O User Guide: http://code.google.com/p/kernel/wiki/AIOUserGuide

#define STAT_TIME_TO_FILETIME (   _t)    (((UINT64)(_t) + EPOCH_DIFF) * 10000000LL)
#define TAG   WINPR_TAG("file")

WinPR: Windows Portable Runtime File Functions

Copyright 2012 Marc-Andre Moreau marca.nosp@m.ndre.nosp@m..more.nosp@m.au@g.nosp@m.mail..nosp@m.com Copyright 2014 Hewlett-Packard Development Company, L.P. 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 void _HandleCreatorsInit ( )
static

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL ConvertFindDataAToW ( LPWIN32_FIND_DATAA  lpFindFileDataA,
LPWIN32_FIND_DATAW  lpFindFileDataW 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL CreateDirectoryA ( LPCSTR  lpPathName,
LPSECURITY_ATTRIBUTES  lpSecurityAttributes 
)

Here is the caller graph for this function:

BOOL CreateDirectoryW ( LPCWSTR  lpPathName,
LPSECURITY_ATTRIBUTES  lpSecurityAttributes 
)

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the call graph for this function:

Here is the caller graph for this function:

HANDLE CreateFileW ( LPCWSTR  lpFileName,
DWORD  dwDesiredAccess,
DWORD  dwShareMode,
LPSECURITY_ATTRIBUTES  lpSecurityAttributes,
DWORD  dwCreationDisposition,
DWORD  dwFlagsAndAttributes,
HANDLE  hTemplateFile 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL DeleteFileA ( LPCSTR  lpFileName)

Here is the caller graph for this function:

BOOL DeleteFileW ( LPCWSTR  lpFileName)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL FindClose ( HANDLE  hFindFile)

Here is the caller graph for this function:

static BOOL FindDataFromStat ( const char *  path,
const struct stat *  fileStat,
LPWIN32_FIND_DATAA  lpFindFileData 
)
static

Here is the caller graph for this function:

HANDLE FindFirstFileA ( LPCSTR  lpFileName,
LPWIN32_FIND_DATAA  lpFindFileData 
)

Here is the call graph for this function:

Here is the caller graph for this function:

HANDLE FindFirstFileExA ( LPCSTR  lpFileName,
FINDEX_INFO_LEVELS  fInfoLevelId,
LPVOID  lpFindFileData,
FINDEX_SEARCH_OPS  fSearchOp,
LPVOID  lpSearchFilter,
DWORD  dwAdditionalFlags 
)

Here is the caller graph for this function:

HANDLE FindFirstFileExW ( LPCWSTR  lpFileName,
FINDEX_INFO_LEVELS  fInfoLevelId,
LPVOID  lpFindFileData,
FINDEX_SEARCH_OPS  fSearchOp,
LPVOID  lpSearchFilter,
DWORD  dwAdditionalFlags 
)

Here is the caller graph for this function:

HANDLE FindFirstFileW ( LPCWSTR  lpFileName,
LPWIN32_FIND_DATAW  lpFindFileData 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL FindNextFileA ( HANDLE  hFindFile,
LPWIN32_FIND_DATAA  lpFindFileData 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL FindNextFileW ( HANDLE  hFindFile,
LPWIN32_FIND_DATAW  lpFindFileData 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL FlushFileBuffers ( HANDLE  hFile)

Here is the call graph for this function:

DWORD WINAPI GetFileAttributesA ( LPCSTR  lpFileName)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL WINAPI GetFileAttributesExA ( LPCSTR  lpFileName,
GET_FILEEX_INFO_LEVELS  fInfoLevelId,
LPVOID  lpFileInformation 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL WINAPI GetFileAttributesExW ( LPCWSTR  lpFileName,
GET_FILEEX_INFO_LEVELS  fInfoLevelId,
LPVOID  lpFileInformation 
)

Here is the call graph for this function:

Here is the caller graph for this function:

DWORD WINAPI GetFileAttributesW ( LPCWSTR  lpFileName)

Here is the call graph for this function:

Here is the caller graph for this function:

DWORD WINAPI GetFileSize ( HANDLE  hFile,
LPDWORD  lpFileSizeHigh 
)

Here is the call graph for this function:

Here is the caller graph for this function:

HANDLE_CREATOR* GetNamedPipeClientHandleCreator ( void  )

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL LockFile ( HANDLE  hFile,
DWORD  dwFileOffsetLow,
DWORD  dwFileOffsetHigh,
DWORD  nNumberOfBytesToLockLow,
DWORD  nNumberOfBytesToLockHigh 
)

Here is the call graph for this function:

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

Here is the call graph for this function:

BOOL MoveFileA ( LPCSTR  lpExistingFileName,
LPCSTR  lpNewFileName 
)

Here is the call graph for this function:

BOOL MoveFileExA ( LPCSTR  lpExistingFileName,
LPCSTR  lpNewFileName,
DWORD  dwFlags 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL MoveFileExW ( LPCWSTR  lpExistingFileName,
LPCWSTR  lpNewFileName,
DWORD  dwFlags 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL MoveFileW ( LPCWSTR  lpExistingFileName,
LPCWSTR  lpNewFileName 
)

Here is the call graph for this function:

BOOL ReadFile ( HANDLE  hFile,
LPVOID  lpBuffer,
DWORD  nNumberOfBytesToRead,
LPDWORD  lpNumberOfBytesRead,
LPOVERLAPPED  lpOverlapped 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL ReadFileEx ( HANDLE  hFile,
LPVOID  lpBuffer,
DWORD  nNumberOfBytesToRead,
LPOVERLAPPED  lpOverlapped,
LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine 
)

Here is the call graph for this function:

BOOL ReadFileScatter ( HANDLE  hFile,
FILE_SEGMENT_ELEMENT  aSegmentArray[],
DWORD  nNumberOfBytesToRead,
LPDWORD  lpReserved,
LPOVERLAPPED  lpOverlapped 
)

Here is the call graph for this function:

BOOL RemoveDirectoryA ( LPCSTR  lpPathName)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL RemoveDirectoryW ( LPCWSTR  lpPathName)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL SetEndOfFile ( HANDLE  hFile)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL SetFileAttributesA ( LPCSTR  lpFileName,
DWORD  dwFileAttributes 
)

Here is the caller graph for this function:

BOOL SetFileAttributesW ( LPCWSTR  lpFileName,
DWORD  dwFileAttributes 
)

Here is the call graph for this function:

Here is the caller graph for this function:

DWORD SetFilePointer ( HANDLE  hFile,
LONG  lDistanceToMove,
PLONG  lpDistanceToMoveHigh,
DWORD  dwMoveMethod 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL SetFilePointerEx ( HANDLE  hFile,
LARGE_INTEGER  liDistanceToMove,
PLARGE_INTEGER  lpNewFilePointer,
DWORD  dwMoveMethod 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL WINAPI SetFileTime ( HANDLE  hFile,
const FILETIME *  lpCreationTime,
const FILETIME *  lpLastAccessTime,
const FILETIME *  lpLastWriteTime 
)

Here is the call graph for this function:

Here is the caller graph for this function:

int UnixChangeFileMode ( const char *  filename,
int  flags 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL UnlockFile ( HANDLE  hFile,
DWORD  dwFileOffsetLow,
DWORD  dwFileOffsetHigh,
DWORD  nNumberOfBytesToUnlockLow,
DWORD  nNumberOfBytesToUnlockHigh 
)

Here is the call graph for this function:

BOOL UnlockFileEx ( HANDLE  hFile,
DWORD  dwReserved,
DWORD  nNumberOfBytesToUnlockLow,
DWORD  nNumberOfBytesToUnlockHigh,
LPOVERLAPPED  lpOverlapped 
)

Here is the call graph for this function:

BOOL WriteFile ( HANDLE  hFile,
LPCVOID  lpBuffer,
DWORD  nNumberOfBytesToWrite,
LPDWORD  lpNumberOfBytesWritten,
LPOVERLAPPED  lpOverlapped 
)

Here is the call graph for this function:

Here is the caller graph for this function:

BOOL WriteFileEx ( HANDLE  hFile,
LPCVOID  lpBuffer,
DWORD  nNumberOfBytesToWrite,
LPOVERLAPPED  lpOverlapped,
LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine 
)

Here is the call graph for this function:

BOOL WriteFileGather ( HANDLE  hFile,
FILE_SEGMENT_ELEMENT  aSegmentArray[],
DWORD  nNumberOfBytesToWrite,
LPDWORD  lpReserved,
LPOVERLAPPED  lpOverlapped 
)

Here is the call graph for this function:

Variable Documentation

wArrayList* _HandleCreators
static
pthread_once_t _HandleCreatorsInitialized = PTHREAD_ONCE_INIT
static