mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: gvfs plugin (add FsGetFile)
This commit is contained in:
parent
a28ff6acee
commit
f372c84010
1 changed files with 61 additions and 50 deletions
|
|
@ -46,11 +46,14 @@
|
|||
G_FILE_ATTRIBUTE_TIME_ACCESS "," G_FILE_ATTRIBUTE_TIME_CREATED "," \
|
||||
G_FILE_ATTRIBUTE_UNIX_MODE "," G_FILE_ATTRIBUTE_UNIX_UID "," \
|
||||
G_FILE_ATTRIBUTE_UNIX_GID
|
||||
#define TUXCMD_DEFAULT_COPY_FLAGS G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS | G_FILE_COPY_ALL_METADATA
|
||||
|
||||
#define GROUP_NAME "gvfs"
|
||||
#define PathDelim "/"
|
||||
#define cAddConnection "<Add connection>"
|
||||
#define cQuickConnection "<Quick connection>"
|
||||
#define IS_DIR_SEP(ch) ((ch) == '/')
|
||||
#define Int32x32To64(a,b) ((gint64)(a)*(gint64)(b))
|
||||
|
||||
|
||||
struct TVFSGlobs {
|
||||
|
|
@ -968,58 +971,8 @@ vfs_copy_progress_callback (goffset current_num_bytes,
|
|||
}
|
||||
}
|
||||
|
||||
#define TUXCMD_DEFAULT_COPY_FLAGS G_FILE_COPY_OVERWRITE | G_FILE_COPY_NOFOLLOW_SYMLINKS | G_FILE_COPY_ALL_METADATA
|
||||
|
||||
TVFSResult
|
||||
VFSCopyOut (struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, gboolean Append)
|
||||
{
|
||||
GFile *src, *dst;
|
||||
GError *error;
|
||||
TVFSResult res;
|
||||
|
||||
|
||||
if (globs->file == NULL) {
|
||||
g_print ("(EE) VFSCopyOut: globs->file == NULL !\n");
|
||||
return cVFS_Failed;
|
||||
}
|
||||
|
||||
g_print ("(II) VFSCopyOut: '%s' --> '%s'\n", sSrcName, sDstName);
|
||||
|
||||
src = g_file_resolve_relative_path (globs->file, sSrcName);
|
||||
if (src == NULL) {
|
||||
g_print ("(EE) VFSCopyOut: g_file_resolve_relative_path() failed.\n");
|
||||
return cVFS_Failed;
|
||||
}
|
||||
dst = g_file_new_for_path (sDstName);
|
||||
if (dst == NULL) {
|
||||
g_print ("(EE) VFSCopyOut: g_file_resolve_relative_path() failed.\n");
|
||||
return cVFS_Failed;
|
||||
}
|
||||
|
||||
globs->cancellable = g_cancellable_new ();
|
||||
|
||||
res = cVFS_OK;
|
||||
error = NULL;
|
||||
g_file_copy (src, dst, TUXCMD_DEFAULT_COPY_FLAGS, globs->cancellable, vfs_copy_progress_callback, globs, &error);
|
||||
if (error) {
|
||||
g_print ("(EE) VFSCopyOut: g_file_copy() error: %s\n", error->message);
|
||||
// res = g_error_to_TVFSResult (error);
|
||||
if (error->code == G_IO_ERROR_CANCELLED)
|
||||
res = cVFS_Cancelled;
|
||||
else res = cVFS_ReadErr;
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_object_unref (globs->cancellable);
|
||||
g_object_unref (src);
|
||||
g_object_unref (dst);
|
||||
return res;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------
|
||||
|
||||
#define Int32x32To64(a,b) ((gint64)(a)*(gint64)(b))
|
||||
|
||||
unsigned long FileTimeToUnixTime(LPFILETIME ft)
|
||||
{
|
||||
gint64 ll = ft->dwHighDateTime;
|
||||
|
|
@ -1762,6 +1715,64 @@ int __stdcall FsRenMovFile(char* OldName,char* NewName,BOOL Move,
|
|||
return FS_FILE_OK;
|
||||
}
|
||||
|
||||
int __stdcall FsGetFile(char* RemoteName,char* LocalName,int CopyFlags,
|
||||
RemoteInfoStruct* ri)
|
||||
{
|
||||
struct TVFSGlobs *globs;
|
||||
GFile *src, *dst;
|
||||
GError *error;
|
||||
TVFSResult res;
|
||||
char *sSrcName;
|
||||
char *sDstName;
|
||||
|
||||
globs = GetConnectionByPath(RemoteName);
|
||||
|
||||
if (globs == NULL) {
|
||||
g_print ("(EE) FsGetFile: globs == NULL !\n");
|
||||
return FS_FILE_NOTSUPPORTED;
|
||||
}
|
||||
if (globs->file == NULL) {
|
||||
g_print ("(EE) FsGetFile: globs->file == NULL !\n");
|
||||
return FS_FILE_NOTSUPPORTED;
|
||||
}
|
||||
|
||||
sSrcName = globs->RemotePath;
|
||||
sDstName = LocalName;
|
||||
|
||||
g_print ("(II) FsGetFile: '%s' --> '%s'\n", sSrcName, sDstName);
|
||||
|
||||
src = g_file_resolve_relative_path (globs->file, sSrcName);
|
||||
if (src == NULL) {
|
||||
g_print ("(EE) FsGetFile: g_file_resolve_relative_path() failed.\n");
|
||||
return FS_FILE_NOTFOUND;
|
||||
}
|
||||
dst = g_file_new_for_path (sDstName);
|
||||
if (dst == NULL) {
|
||||
g_print ("(EE) FsGetFile: g_file_resolve_relative_path() failed.\n");
|
||||
return FS_FILE_NOTFOUND;
|
||||
}
|
||||
|
||||
globs->cancellable = g_cancellable_new ();
|
||||
|
||||
res = FS_FILE_OK;
|
||||
error = NULL;
|
||||
g_file_copy (src, dst, TUXCMD_DEFAULT_COPY_FLAGS, globs->cancellable, vfs_copy_progress_callback, globs, &error);
|
||||
if (error) {
|
||||
g_print ("(EE) FsGetFile: g_file_copy() error: %s\n", error->message);
|
||||
// res = g_error_to_TVFSResult (error);
|
||||
if (error->code == G_IO_ERROR_CANCELLED)
|
||||
res = FS_FILE_USERABORT;
|
||||
else
|
||||
res = FS_FILE_READERROR;
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_object_unref (globs->cancellable);
|
||||
g_object_unref (src);
|
||||
g_object_unref (dst);
|
||||
return res;
|
||||
}
|
||||
|
||||
int __stdcall FsPutFile(char* LocalName,char* RemoteName,int CopyFlags)
|
||||
{
|
||||
struct TVFSGlobs *globs;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue