fbe8a2eaae
Currently not working are rename and setting of read only attribute and file times. In addition it also adds the ability to staticly link plugins into the binary, so you get one big exe and need no dlls. I have only tested this on windows (only disk plugin so far). I use the following options for cmake for static binary: cmake -DWITH_MONOLITHIC_BUILD=ON -DMSVC_RUNTIME=static -DBUILD_SHARED_LIBS=OFF -DWITH_RDPDR=ON -DOPENSSL_INCLUDE_DIR=\opensslpath\inc32 -DOPENSSL_LIBRARIES="\opensslpath\out32.dbg\ssleay32.lib;d:\path\out32.dbg\libeay32.lib" -G "Visual Studio 9 2008" . Important notice: Openssl need to be compiled with the same static runtime. Currently missing is a switch to link different openssl libraries for debug and release builds.
110 lines
3.1 KiB
C
110 lines
3.1 KiB
C
/**
|
|
* FreeRDP: A Remote Desktop Protocol client.
|
|
* File System Virtual Channel
|
|
*
|
|
* Copyright 2010-2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
* Copyright 2010-2011 Vic Lee
|
|
* Copyright 2012 Gerald Richter
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#ifndef __DISK_FILE_H
|
|
#define __DISK_FILE_H
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
|
|
#include "dirent.h"
|
|
#ifdef _WIN32
|
|
#include <direct.h>
|
|
#include <io.h>
|
|
#include "statvfs.h"
|
|
#else
|
|
#include <sys/statvfs.h>
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
|
#define STAT stat
|
|
#define OPEN _open
|
|
#define close _close
|
|
#define read _read
|
|
#define write _write
|
|
#define LSEEK _lseek
|
|
#define FSTAT fstat
|
|
#define STATVFS statvfs
|
|
#define mkdir(a,b) _mkdir(a)
|
|
#define rmdir _rmdir
|
|
#define unlink(a) _unlink(a)
|
|
#define ftruncate(a,b) _chsize(a,b)
|
|
|
|
typedef uint32 ssize_t ;
|
|
typedef uint32 mode_t ;
|
|
|
|
#elif defined(__APPLE__) || defined(__FreeBSD__)
|
|
#define STAT stat
|
|
#define OPEN open
|
|
#define LSEEK lseek
|
|
#define FSTAT fstat
|
|
#define STATVFS statvfs
|
|
#define O_LARGEFILE 0
|
|
#else
|
|
#define STAT stat64
|
|
#define OPEN open64
|
|
#define LSEEK lseek64
|
|
#define FSTAT fstat64
|
|
#define STATVFS statvfs64
|
|
#endif
|
|
|
|
#define EPOCH_DIFF 11644473600LL
|
|
|
|
#define FILE_TIME_SYSTEM_TO_RDP(_t) \
|
|
(((uint64)(_t) + EPOCH_DIFF) * 10000000LL)
|
|
#define FILE_TIME_RDP_TO_SYSTEM(_t) \
|
|
(((_t) == 0LL || (_t) == (uint64)(-1LL)) ? 0 : (time_t)((_t) / 10000000LL - EPOCH_DIFF))
|
|
|
|
#define FILE_ATTR_SYSTEM_TO_RDP(_f, _st) ( \
|
|
(S_ISDIR(_st.st_mode) ? FILE_ATTRIBUTE_DIRECTORY : 0) | \
|
|
(_f->filename[0] == '.' ? FILE_ATTRIBUTE_HIDDEN : 0) | \
|
|
(_f->delete_pending ? FILE_ATTRIBUTE_TEMPORARY : 0) | \
|
|
(st.st_mode & S_IWUSR ? 0 : FILE_ATTRIBUTE_READONLY))
|
|
|
|
typedef struct _DISK_FILE DISK_FILE;
|
|
struct _DISK_FILE
|
|
{
|
|
uint32 id;
|
|
boolean is_dir;
|
|
int fd;
|
|
int err;
|
|
DIR* dir;
|
|
char* basepath;
|
|
char* fullpath;
|
|
char* filename;
|
|
char* pattern;
|
|
boolean delete_pending;
|
|
};
|
|
|
|
DISK_FILE* disk_file_new(const char* base_path, const char* path, uint32 id,
|
|
uint32 DesiredAccess, uint32 CreateDisposition, uint32 CreateOptions);
|
|
void disk_file_free(DISK_FILE* file);
|
|
|
|
boolean disk_file_seek(DISK_FILE* file, uint64 Offset);
|
|
boolean disk_file_read(DISK_FILE* file, uint8* buffer, uint32* Length);
|
|
boolean disk_file_write(DISK_FILE* file, uint8* buffer, uint32 Length);
|
|
boolean disk_file_query_information(DISK_FILE* file, uint32 FsInformationClass, STREAM* output);
|
|
boolean disk_file_set_information(DISK_FILE* file, uint32 FsInformationClass, uint32 Length, STREAM* input);
|
|
boolean disk_file_query_directory(DISK_FILE* file, uint32 FsInformationClass, uint8 InitialQuery,
|
|
const char* path, STREAM* output);
|
|
|
|
#endif /* __DISK_FILE_H */
|