2011-08-07 07:21:42 +04:00
|
|
|
/**
|
2012-10-09 05:00:07 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-08-07 07:21:42 +04:00
|
|
|
* File System Virtual Channel
|
|
|
|
*
|
2012-10-09 05:00:07 +04:00
|
|
|
* Copyright 2010-2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2011-08-07 07:21:42 +04:00
|
|
|
* Copyright 2010-2011 Vic Lee
|
2012-10-09 05:00:07 +04:00
|
|
|
* Copyright 2012 Gerald Richter
|
2011-08-07 07:21:42 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2012-11-03 03:59:07 +04:00
|
|
|
#ifndef FREERDP_CHANNEL_DRIVE_FILE_H
|
|
|
|
#define FREERDP_CHANNEL_DRIVE_FILE_H
|
2011-08-07 07:21:42 +04:00
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2012-10-02 10:58:54 +04:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <direct.h>
|
|
|
|
#include <io.h>
|
2012-10-02 18:57:39 +04:00
|
|
|
#include "dirent.h"
|
2012-10-02 10:58:54 +04:00
|
|
|
#include "statvfs.h"
|
|
|
|
#else
|
2012-10-02 18:57:39 +04:00
|
|
|
#include <dirent.h>
|
2012-10-14 04:31:01 +04:00
|
|
|
#ifdef ANDROID
|
|
|
|
#include <sys/vfs.h>
|
|
|
|
#else
|
2012-07-29 06:24:14 +04:00
|
|
|
#include <sys/statvfs.h>
|
|
|
|
#endif
|
2012-10-14 04:31:01 +04:00
|
|
|
#endif
|
2011-08-07 07:21:42 +04:00
|
|
|
|
2012-07-29 06:24:14 +04:00
|
|
|
#ifdef _WIN32
|
2012-03-09 14:53:32 +04:00
|
|
|
#define STAT stat
|
2012-10-02 10:58:54 +04:00
|
|
|
#define OPEN _open
|
|
|
|
#define close _close
|
|
|
|
#define read _read
|
|
|
|
#define write _write
|
|
|
|
#define LSEEK _lseek
|
2012-03-09 14:53:32 +04:00
|
|
|
#define FSTAT fstat
|
2012-04-18 13:52:49 +04:00
|
|
|
#define STATVFS statvfs
|
2012-10-02 10:58:54 +04:00
|
|
|
#define mkdir(a,b) _mkdir(a)
|
|
|
|
#define rmdir _rmdir
|
|
|
|
#define unlink(a) _unlink(a)
|
|
|
|
#define ftruncate(a,b) _chsize(a,b)
|
|
|
|
|
2012-10-14 04:31:01 +04:00
|
|
|
typedef UINT32 ssize_t;
|
|
|
|
typedef UINT32 mode_t;
|
2012-10-02 10:58:54 +04:00
|
|
|
|
2012-03-20 17:26:42 +04:00
|
|
|
#elif defined(__APPLE__) || defined(__FreeBSD__)
|
2012-03-10 17:38:47 +04:00
|
|
|
#define STAT stat
|
|
|
|
#define OPEN open
|
|
|
|
#define LSEEK lseek
|
|
|
|
#define FSTAT fstat
|
2012-04-18 13:52:49 +04:00
|
|
|
#define STATVFS statvfs
|
2012-03-10 17:38:47 +04:00
|
|
|
#define O_LARGEFILE 0
|
2012-03-09 14:53:32 +04:00
|
|
|
#else
|
|
|
|
#define STAT stat64
|
|
|
|
#define OPEN open64
|
|
|
|
#define LSEEK lseek64
|
|
|
|
#define FSTAT fstat64
|
2012-04-18 13:52:49 +04:00
|
|
|
#define STATVFS statvfs64
|
2012-03-09 14:53:32 +04:00
|
|
|
#endif
|
|
|
|
|
2012-04-18 13:52:49 +04:00
|
|
|
#define EPOCH_DIFF 11644473600LL
|
|
|
|
|
|
|
|
#define FILE_TIME_SYSTEM_TO_RDP(_t) \
|
2012-10-09 11:26:39 +04:00
|
|
|
(((UINT64)(_t) + EPOCH_DIFF) * 10000000LL)
|
2012-04-18 13:52:49 +04:00
|
|
|
#define FILE_TIME_RDP_TO_SYSTEM(_t) \
|
2012-10-09 11:26:39 +04:00
|
|
|
(((_t) == 0LL || (_t) == (UINT64)(-1LL)) ? 0 : (time_t)((_t) / 10000000LL - EPOCH_DIFF))
|
2012-04-18 13:52:49 +04:00
|
|
|
|
|
|
|
#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))
|
|
|
|
|
2012-11-03 03:59:07 +04:00
|
|
|
typedef struct _DRIVE_FILE DRIVE_FILE;
|
|
|
|
|
|
|
|
struct _DRIVE_FILE
|
2011-08-07 07:21:42 +04:00
|
|
|
{
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 id;
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL is_dir;
|
2011-08-07 07:21:42 +04:00
|
|
|
int fd;
|
2011-10-19 17:43:04 +04:00
|
|
|
int err;
|
2011-08-07 07:21:42 +04:00
|
|
|
DIR* dir;
|
2011-11-24 10:29:12 +04:00
|
|
|
char* basepath;
|
2011-08-07 07:21:42 +04:00
|
|
|
char* fullpath;
|
2011-08-07 11:17:06 +04:00
|
|
|
char* filename;
|
2011-12-06 07:04:27 +04:00
|
|
|
char* pattern;
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL delete_pending;
|
2011-08-07 07:21:42 +04:00
|
|
|
};
|
|
|
|
|
2012-11-03 03:59:07 +04:00
|
|
|
DRIVE_FILE* drive_file_new(const char* base_path, const char* path, UINT32 id,
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 DesiredAccess, UINT32 CreateDisposition, UINT32 CreateOptions);
|
2012-11-03 03:59:07 +04:00
|
|
|
void drive_file_free(DRIVE_FILE* file);
|
2011-08-07 07:21:42 +04:00
|
|
|
|
2012-11-03 03:59:07 +04:00
|
|
|
BOOL drive_file_seek(DRIVE_FILE* file, UINT64 Offset);
|
|
|
|
BOOL drive_file_read(DRIVE_FILE* file, BYTE* buffer, UINT32* Length);
|
|
|
|
BOOL drive_file_write(DRIVE_FILE* file, BYTE* buffer, UINT32 Length);
|
|
|
|
BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, STREAM* output);
|
|
|
|
BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UINT32 Length, STREAM* input);
|
|
|
|
BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYTE InitialQuery,
|
2011-08-07 15:24:29 +04:00
|
|
|
const char* path, STREAM* output);
|
2011-08-07 09:11:52 +04:00
|
|
|
|
2012-11-03 03:59:07 +04:00
|
|
|
#endif /* FREERDP_CHANNEL_DRIVE_FILE_H */
|