Enlightenment CVS committal
Author : lordchaos
Project : e17
Module : apps/evfs
Dir : e17/apps/evfs/src/bin
Modified Files:
evfs_server_handle.c
Log Message:
* TODO++
* Change the plugin directory list callback - stop the plugin directly invoking
events. This means the server can now use plugins for its' own purpose
* Implement recursive directory copying.
* Latest version of John Kha's FTP plugin
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/bin/evfs_server_handle.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -3 -r1.20 -r1.21
--- evfs_server_handle.c 17 Nov 2005 08:01:56 -0000 1.20
+++ evfs_server_handle.c 19 Nov 2005 10:51:19 -0000 1.21
@@ -1,5 +1,13 @@
#include "evfs.h"
#include <dlfcn.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <dirent.h>
/*---------------------------------------------------*/
@@ -136,7 +144,14 @@
evfs_plugin* plugin = evfs_get_plugin_for_uri(client->server,
command->file_command.files[0]->plugin_uri);
if (plugin) {
- (*plugin->functions->evfs_dir_list)(client,command);
+ Ecore_List* directory_list = NULL;
+ (*plugin->functions->evfs_dir_list)(client,command,
&directory_list);
+
+ if (directory_list) {
+ evfs_list_dir_event_create(client, command,
directory_list);
+ } else {
+ printf("evfs_handle_dir_list_command: Recevied null
from plugin for directory_list\n");
+ }
} else {
printf("No plugin for '%s'\n",
command->file_command.files[0]->plugin_uri);
}
@@ -149,67 +164,116 @@
char bytes[COPY_BLOCKSIZE];
long count;
+ char destination_file[PATH_MAX];
long read_write_bytes = 0;
static struct stat file_stat;
int progress = 0;
int last_notify_progress = 0;
evfs_filereference* ref = NEW(evfs_filereference);
- printf ("At test handler\n");
-
- /*Make a dummy 'to' file for now*/
- /*ref->plugin_uri = strdup("smb");
- ref->plugin = evfs_get_plugin_for_uri(ref->plugin_uri);
- ref->parent = NULL;
- ref->path = strdup("/gown/MythVideos/musicvideos/testcopy.dat");*/
-
-
-
plugin = evfs_get_plugin_for_uri(client->server,
command->file_command.files[0]->plugin_uri);
dst_plugin = evfs_get_plugin_for_uri(client->server,
command->file_command.files[1]->plugin_uri);
if (plugin && dst_plugin) {
-
(*dst_plugin->functions->evfs_file_create)(command->file_command.files[1]);
- (*plugin->functions->evfs_file_open)(client,
command->file_command.files[0]);
+
/*Get the source file size*/
(*plugin->functions->evfs_file_stat)(command, &file_stat);
- printf("Source file size: %d bytes\n", (int)file_stat.st_size);
+ //printf("Source file size: %d bytes\n",
(int)file_stat.st_size);
- count = 0;
- while (count < file_stat.st_size) {
-
(*plugin->functions->evfs_file_seek)(command->file_command.files[0], count,
SEEK_SET);
+ if (!S_ISDIR(file_stat.st_mode)) {
+
(*dst_plugin->functions->evfs_file_create)(command->file_command.files[1]);
+ (*plugin->functions->evfs_file_open)(client,
command->file_command.files[0]);
+
+ count = 0;
+ while (count < file_stat.st_size) {
+
(*plugin->functions->evfs_file_seek)(command->file_command.files[0], count,
SEEK_SET);
- read_write_bytes = (file_stat.st_size > count +
COPY_BLOCKSIZE) ? COPY_BLOCKSIZE : (file_stat.st_size - count);
- /*printf("Reading/writing %d bytes\n",
read_write_bytes);*/
+ read_write_bytes = (file_stat.st_size > count +
COPY_BLOCKSIZE) ? COPY_BLOCKSIZE : (file_stat.st_size - count);
+ /*printf("Reading/writing %d bytes\n",
read_write_bytes);*/
+
+
(*plugin->functions->evfs_file_read)(client,command->file_command.files[0],
bytes, read_write_bytes );
+
(*dst_plugin->functions->evfs_file_write)(command->file_command.files[1],
bytes, read_write_bytes );
+
+ progress = (double)((double)count /
(double)file_stat.st_size * 100);
+ if (progress % 1 == 0 && last_notify_progress <
progress) {
+ /*printf ("Percent complete: %d\n",
progress);*/
+
evfs_file_progress_event_create(client,command,progress,
EVFS_PROGRESS_TYPE_CONTINUE);
+ last_notify_progress = progress;
+ }
-
(*plugin->functions->evfs_file_read)(client,command->file_command.files[0],
bytes, read_write_bytes );
-
(*dst_plugin->functions->evfs_file_write)(command->file_command.files[1],
bytes, read_write_bytes );
+ count+= COPY_BLOCKSIZE;
+
+
+ /*Iterate*/
+ ecore_main_loop_iterate();
+ }
+
(*dst_plugin->functions->evfs_file_close)(command->file_command.files[1]);
+
(*plugin->functions->evfs_file_close)(command->file_command.files[0]);
+ } else {
+ Ecore_List* directory_list = NULL;
- progress = (double)((double)count /
(double)file_stat.st_size * 100);
- if (progress % 5 == 0 && last_notify_progress <
progress) {
- printf ("Percent complete: %d\n", progress);
-
evfs_file_progress_event_create(client,command,progress,
EVFS_PROGRESS_TYPE_CONTINUE);
- last_notify_progress = progress;
+ /*First, we need a directory list...*/
+
(*plugin->functions->evfs_dir_list)(client,command,&directory_list);
+ if (directory_list) {
+ int ret =0;
+
+ /*OK, so the directory exists at the source,
and contains files.
+ * Let's make the destination directory
first..*/
+ printf("Making new directory '%s'",
command->file_command.files[1]->path);
+ ret=
(*dst_plugin->functions->evfs_file_mkdir)(command->file_command.files[1]);
+ printf("....ret was %d\n", ret);
+
+ evfs_filereference* file = NULL;
+ //printf("Recursive directory list for '%s'
received..\n", command->file_command.files[0]->path);
+ while ((file =
ecore_list_remove_first(directory_list))) {
+ evfs_filereference* source =
NEW(evfs_filereference);
+ evfs_filereference* dest =
NEW(evfs_filereference);
+ evfs_command* recursive_command =
NEW(evfs_command);
+
+
+
+ snprintf(destination_file, PATH_MAX,
"%s%s",
+
command->file_command.files[1]->path, strrchr(file->path, '/'));
+
+ source->path = strdup(file->path);
+ source->plugin_uri =
strdup(command->file_command.files[0]->plugin_uri);
+ source->parent = NULL; /*TODO - handle
nested uris*/
+ dest->path = strdup(destination_file);
+ dest->plugin_uri =
strdup(command->file_command.files[1]->plugin_uri);
+ dest->parent = NULL; /*TODO - handle
nested uris*/
+
+ recursive_command->file_command.files =
malloc(sizeof(evfs_filereference*)*2);
+ recursive_command->type =
EVFS_CMD_FILE_COPY;
+
recursive_command->file_command.files[0] = source;
+
recursive_command->file_command.files[1] = dest;
+
recursive_command->file_command.num_files = 2;
+
+ //printf("Copy file '%s' to %s\n",
file->path, destination_file);
+
+ evfs_handle_file_copy(client,
recursive_command);
+
+ evfs_cleanup_filereference(file);
+ evfs_cleanup_command(recursive_command,
1);
+ }
+ ecore_list_destroy(directory_list);
+
}
+
-
- count+= COPY_BLOCKSIZE;
-
- /*Iterate*/
- ecore_main_loop_iterate();
}
-
(*dst_plugin->functions->evfs_file_close)(command->file_command.files[1]);
-
(*plugin->functions->evfs_file_close)(command->file_command.files[0]);
+
evfs_file_progress_event_create(client,command,100,
EVFS_PROGRESS_TYPE_DONE);
+ } else {
+ printf("Could not get plugins for both source and dest:
(%s:%s)\n",command->file_command.files[0]->plugin_uri,
command->file_command.files[1]->plugin_uri );
}
}
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs