FreeRDP
generic.c File Reference
#include <winpr/config.h>
#include <winpr/crt.h>
#include <winpr/string.h>
#include <winpr/path.h>
#include <winpr/file.h>
#include "../log.h"
#include <winpr/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"
#include "../comm/comm.h"

Macros

#define TAG   WINPR_TAG("file")
 

Functions

HANDLE_CREATORGetNamedPipeClientHandleCreator (void)
 
static void HandleCreatorsInit (void)
 
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 GetFileInformationByHandle (HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
 
static char * append (char *buffer, size_t size, const char *append)
 
static const char * flagsToStr (char *buffer, size_t size, DWORD flags)
 
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 WIN32_FILE_SEARCH * file_search_new (const char *name, size_t namelen, const char *pattern, size_t patternlen)
 
static BOOL is_valid_file_search_handle (HANDLE handle)
 
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
 
static const char file_search_magic [] = "file_srch_magic"
 

Macro Definition Documentation

◆ TAG

#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

◆ append()

static char* append ( char *  buffer,
size_t  size,
const char *  append 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConvertFindDataAToW()

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:

◆ CreateDirectoryA()

BOOL CreateDirectoryA ( LPCSTR  lpPathName,
LPSECURITY_ATTRIBUTES  lpSecurityAttributes 
)
Here is the caller graph for this function:

◆ CreateDirectoryW()

BOOL CreateDirectoryW ( LPCWSTR  lpPathName,
LPSECURITY_ATTRIBUTES  lpSecurityAttributes 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateFileA()

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:

◆ CreateFileW()

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:

◆ DeleteFileA()

BOOL DeleteFileA ( LPCSTR  lpFileName)
Here is the caller graph for this function:

◆ DeleteFileW()

BOOL DeleteFileW ( LPCWSTR  lpFileName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_search_new()

static WIN32_FILE_SEARCH* file_search_new ( const char *  name,
size_t  namelen,
const char *  pattern,
size_t  patternlen 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindClose()

BOOL FindClose ( HANDLE  hFindFile)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindDataFromStat()

static BOOL FindDataFromStat ( const char *  path,
const struct stat *  fileStat,
LPWIN32_FIND_DATAA  lpFindFileData 
)
static
Here is the caller graph for this function:

◆ FindFirstFileA()

HANDLE FindFirstFileA ( LPCSTR  lpFileName,
LPWIN32_FIND_DATAA  lpFindFileData 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindFirstFileExA()

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

◆ FindFirstFileExW()

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

◆ FindFirstFileW()

HANDLE FindFirstFileW ( LPCWSTR  lpFileName,
LPWIN32_FIND_DATAW  lpFindFileData 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindNextFileA()

BOOL FindNextFileA ( HANDLE  hFindFile,
LPWIN32_FIND_DATAA  lpFindFileData 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindNextFileW()

BOOL FindNextFileW ( HANDLE  hFindFile,
LPWIN32_FIND_DATAW  lpFindFileData 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flagsToStr()

static const char* flagsToStr ( char *  buffer,
size_t  size,
DWORD  flags 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FlushFileBuffers()

BOOL FlushFileBuffers ( HANDLE  hFile)
Here is the call graph for this function:

◆ GetFileAttributesA()

DWORD WINAPI GetFileAttributesA ( LPCSTR  lpFileName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFileAttributesExA()

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:

◆ GetFileAttributesExW()

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:

◆ GetFileAttributesW()

DWORD WINAPI GetFileAttributesW ( LPCWSTR  lpFileName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFileInformationByHandle()

BOOL GetFileInformationByHandle ( HANDLE  hFile,
LPBY_HANDLE_FILE_INFORMATION  lpFileInformation 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFileSize()

DWORD WINAPI GetFileSize ( HANDLE  hFile,
LPDWORD  lpFileSizeHigh 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNamedPipeClientHandleCreator()

HANDLE_CREATOR * GetNamedPipeClientHandleCreator ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleCreatorsInit()

static void HandleCreatorsInit ( void  )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_valid_file_search_handle()

static BOOL is_valid_file_search_handle ( HANDLE  handle)
static
Here is the caller graph for this function:

◆ LockFile()

BOOL LockFile ( HANDLE  hFile,
DWORD  dwFileOffsetLow,
DWORD  dwFileOffsetHigh,
DWORD  nNumberOfBytesToLockLow,
DWORD  nNumberOfBytesToLockHigh 
)
Here is the call graph for this function:

◆ LockFileEx()

BOOL LockFileEx ( HANDLE  hFile,
DWORD  dwFlags,
DWORD  dwReserved,
DWORD  nNumberOfBytesToLockLow,
DWORD  nNumberOfBytesToLockHigh,
LPOVERLAPPED  lpOverlapped 
)
Here is the call graph for this function:

◆ MoveFileA()

BOOL MoveFileA ( LPCSTR  lpExistingFileName,
LPCSTR  lpNewFileName 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MoveFileExA()

BOOL MoveFileExA ( LPCSTR  lpExistingFileName,
LPCSTR  lpNewFileName,
DWORD  dwFlags 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MoveFileExW()

BOOL MoveFileExW ( LPCWSTR  lpExistingFileName,
LPCWSTR  lpNewFileName,
DWORD  dwFlags 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MoveFileW()

BOOL MoveFileW ( LPCWSTR  lpExistingFileName,
LPCWSTR  lpNewFileName 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadFile()

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:

◆ ReadFileEx()

BOOL ReadFileEx ( HANDLE  hFile,
LPVOID  lpBuffer,
DWORD  nNumberOfBytesToRead,
LPOVERLAPPED  lpOverlapped,
LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine 
)
Here is the call graph for this function:

◆ ReadFileScatter()

BOOL ReadFileScatter ( HANDLE  hFile,
FILE_SEGMENT_ELEMENT  aSegmentArray[],
DWORD  nNumberOfBytesToRead,
LPDWORD  lpReserved,
LPOVERLAPPED  lpOverlapped 
)
Here is the call graph for this function:

◆ RemoveDirectoryA()

BOOL RemoveDirectoryA ( LPCSTR  lpPathName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveDirectoryW()

BOOL RemoveDirectoryW ( LPCWSTR  lpPathName)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetEndOfFile()

BOOL SetEndOfFile ( HANDLE  hFile)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFileAttributesA()

BOOL SetFileAttributesA ( LPCSTR  lpFileName,
DWORD  dwFileAttributes 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFileAttributesW()

BOOL SetFileAttributesW ( LPCWSTR  lpFileName,
DWORD  dwFileAttributes 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetFilePointer()

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:

◆ SetFilePointerEx()

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:

◆ SetFileTime()

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:

◆ UnixChangeFileMode()

int UnixChangeFileMode ( const char *  filename,
int  flags 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnlockFile()

BOOL UnlockFile ( HANDLE  hFile,
DWORD  dwFileOffsetLow,
DWORD  dwFileOffsetHigh,
DWORD  nNumberOfBytesToUnlockLow,
DWORD  nNumberOfBytesToUnlockHigh 
)
Here is the call graph for this function:

◆ UnlockFileEx()

BOOL UnlockFileEx ( HANDLE  hFile,
DWORD  dwReserved,
DWORD  nNumberOfBytesToUnlockLow,
DWORD  nNumberOfBytesToUnlockHigh,
LPOVERLAPPED  lpOverlapped 
)
Here is the call graph for this function:

◆ WriteFile()

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:

◆ WriteFileEx()

BOOL WriteFileEx ( HANDLE  hFile,
LPCVOID  lpBuffer,
DWORD  nNumberOfBytesToWrite,
LPOVERLAPPED  lpOverlapped,
LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine 
)
Here is the call graph for this function:

◆ WriteFileGather()

BOOL WriteFileGather ( HANDLE  hFile,
FILE_SEGMENT_ELEMENT  aSegmentArray[],
DWORD  nNumberOfBytesToWrite,
LPDWORD  lpReserved,
LPOVERLAPPED  lpOverlapped 
)
Here is the call graph for this function:

Variable Documentation

◆ file_search_magic

const char file_search_magic[] = "file_srch_magic"
static

◆ HandleCreators

wArrayList* HandleCreators
static

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

◆ HandleCreatorsInitialized

pthread_once_t HandleCreatorsInitialized = PTHREAD_ONCE_INIT
static