Enlightenment CVS committal
Author : chaos
Project : e17
Module : apps/evfs
Dir : e17/apps/evfs/src/plugins/file
Modified Files:
evfs_fs_bzip2.c evfs_fs_gzip.c evfs_fs_posix.c evfs_fs_samba.c
evfs_fs_sftp.c evfs_fs_tar.c evfs_fs_trash.c evfs_fs_vfolder.c
Log Message:
* File copy master function put through regression testing. Tested ok.
* API change - evfs_dir_list now takes a file, not a command, in the plugins
* Trashing files and entire dir trees now works. Multiple deletes of the same
file/dir also work.
===================================================================
RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_bzip2.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- evfs_fs_bzip2.c 21 Apr 2006 15:10:17 -0000 1.1
+++ evfs_fs_bzip2.c 20 Aug 2006 04:13:57 -0000 1.2
@@ -53,7 +53,7 @@
char *bytes, long size);
int evfs_file_write(evfs_filereference * file, char *bytes, long size);
int evfs_file_create(evfs_filereference * file);
-void evfs_dir_list(evfs_client * client, evfs_command * file);
+void evfs_dir_list(evfs_client * client, evfs_filereference* file);
#define BZIP2_BUFFER 5000
#define EVFS_BZ2_GOT_DATA -1
===================================================================
RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_gzip.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- evfs_fs_gzip.c 21 Apr 2006 15:10:17 -0000 1.1
+++ evfs_fs_gzip.c 20 Aug 2006 04:13:57 -0000 1.2
@@ -53,7 +53,7 @@
char *bytes, long size);
int evfs_file_write(evfs_filereference * file, char *bytes, long size);
int evfs_file_create(evfs_filereference * file);
-void evfs_dir_list(evfs_client * client, evfs_command * file);
+void evfs_dir_list(evfs_client * client, evfs_filereference * file);
#define GZIP_BUFFER 16384
#define GZIP_MAX_ERRORS 5
===================================================================
RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_posix.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- evfs_fs_posix.c 15 Aug 2006 12:04:32 -0000 1.3
+++ evfs_fs_posix.c 20 Aug 2006 04:13:57 -0000 1.4
@@ -57,7 +57,7 @@
int evfs_file_write(evfs_filereference * file, char *bytes, long size);
int evfs_file_create(evfs_filereference * file);
int evfs_file_mkdir(evfs_filereference * file);
-void evfs_dir_list(evfs_client * client, evfs_command * command,
+void evfs_dir_list(evfs_client * client, evfs_filereference* ref,
Ecore_List ** directory_list);
/*Internal functions */
@@ -507,7 +507,7 @@
}
void
-evfs_dir_list(evfs_client * client, evfs_command * command,
+evfs_dir_list(evfs_client * client, evfs_filereference* file,
Ecore_List ** directory_list)
{
struct dirent *de;
@@ -516,7 +516,7 @@
Ecore_List *files = ecore_list_new();
char full_name[PATH_MAX];
- dir = opendir(command->file_command.files[0]->path);
+ dir = opendir(file->path);
while ((de = readdir(dir)))
{
if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")
@@ -525,7 +525,7 @@
evfs_filereference *ref = NEW(evfs_filereference);
snprintf(full_name, 1024, "%s/%s",
- command->file_command.files[0]->path, de->d_name);
+ file->path, de->d_name);
stat(full_name, &st);
if (S_ISDIR(st.st_mode))
{
===================================================================
RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_samba.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- evfs_fs_samba.c 5 Aug 2006 12:25:10 -0000 1.6
+++ evfs_fs_samba.c 20 Aug 2006 04:13:57 -0000 1.7
@@ -51,7 +51,7 @@
int smb_next_fd;
Ecore_Hash *smb_fd_hash;
-static void smb_evfs_dir_list(evfs_client * client, evfs_command * command,
+static void smb_evfs_dir_list(evfs_client * client, evfs_filereference*
command,
Ecore_List ** directory_list);
int smb_evfs_file_stat(evfs_command * command, struct stat *file_stat, int);
int evfs_file_open(evfs_client * client, evfs_filereference * file);
@@ -286,7 +286,7 @@
}
static void
-smb_evfs_dir_list(evfs_client * client, evfs_command * command,
+smb_evfs_dir_list(evfs_client * client, evfs_filereference * file,
/*Returns.. */
Ecore_List ** directory_list)
{
@@ -302,17 +302,17 @@
Ecore_List *files = ecore_list_new();
/*Does this command have an attached authentication object? */
- if (command->file_command.files[0]->username)
+ if (file->username)
{
printf("We have a username, adding to hash..\n");
evfs_auth_structure_add(auth_cache,
- command->file_command.files[0]->username,
- command->file_command.files[0]->password,
- command->file_command.files[0]->path);
+ file->username,
+ file->password,
+ file->path);
}
//Reappend smb protocol header for libsmbclient..
- snprintf(dir_path, 1024, "smb:/%s", command->file_command.files[0]->path);
+ snprintf(dir_path, 1024, "smb:/%s", file->path);
printf("evfs_fs_samba: Listing directory %s\n", dir_path);
@@ -348,12 +348,12 @@
size =
(sizeof(char) *
- strlen(command->file_command.files[0]->path)) +
+ strlen(file->path)) +
(sizeof(char) * strlen(entry->name)) + (sizeof(char) * 2);
reference->path = malloc(size);
snprintf(reference->path, size, "%s/%s",
- command->file_command.files[0]->path, entry->name);
+ file->path, entry->name);
/*printf("File '%s' is of type '%d'\n", reference->path,
reference->file_type); */
===================================================================
RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_sftp.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- evfs_fs_sftp.c 22 Jul 2006 06:09:27 -0000 1.3
+++ evfs_fs_sftp.c 20 Aug 2006 04:13:57 -0000 1.4
@@ -801,7 +801,7 @@
/*----------------------------------------------------------------*/
void
-evfs_dir_list(evfs_client * client, evfs_command * command, Ecore_List **
directory_list);
+evfs_dir_list(evfs_client * client, evfs_filereference* ref, Ecore_List **
directory_list);
int evfs_file_open(evfs_client * client, evfs_filereference * file);
int evfs_file_close(evfs_filereference * file);
int evfs_file_seek(evfs_filereference * file, long offset, int whence);
@@ -1100,7 +1100,7 @@
}
void
-evfs_dir_list(evfs_client * client, evfs_command * command,
+evfs_dir_list(evfs_client * client, evfs_filereference* iref,
/*Returns.. */
Ecore_List ** directory_list)
{
@@ -1113,9 +1113,9 @@
char* host, *schar;
SftpConnection* conn = NULL;
- sftp_split_host_path(command->file_command.files[0]->path,
&host,&schar);
+ sftp_split_host_path(iref->path, &host,&schar);
- printf("Original: %s\n", command->file_command.files[0]->path);
+ printf("Original: %s\n", iref->path);
printf("Listing directory '%s' on host '%s', using sftp\n", schar, host
);
if ( !(conn = sftp_get_connection_for_host(host))) {
===================================================================
RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_tar.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- evfs_fs_tar.c 21 Apr 2006 15:10:17 -0000 1.1
+++ evfs_fs_tar.c 20 Aug 2006 04:13:57 -0000 1.2
@@ -90,7 +90,7 @@
int evfs_file_read(evfs_filereference * file, char *bytes, long size);
int evfs_file_write(evfs_filereference * file, char *bytes, long size);
int evfs_file_create(evfs_filereference * file);
-void evfs_dir_list(evfs_client * client, evfs_command * file,
+void evfs_dir_list(evfs_client * client, evfs_filereference * file,
Ecore_List ** directory_list);
struct tar_file
@@ -429,7 +429,7 @@
}
void
-evfs_dir_list(evfs_client * client, evfs_command * com,
+evfs_dir_list(evfs_client * client, evfs_filereference *ref,
/*Returns..*/
Ecore_List ** directory_list)
{
@@ -440,18 +440,17 @@
Ecore_List *files = ecore_list_new();
char *key;
- printf("Listing tar file dir: '%s'\n", com->file_command.files[0]->path);
+ printf("Listing tar file dir: '%s'\n", ref->path);
if (!
(file =
ecore_hash_get(tar_cache,
- evfs_file_top_level_find(com->file_command.files[0])->
- path)))
+ evfs_file_top_level_find(ref->path))))
{
- file = evfs_tar_load_tar(client, com->file_command.files[0]);
+ file = evfs_tar_load_tar(client, ref);
}
- if (!strcmp(com->file_command.files[0]->path, "/"))
+ if (!strcmp(ref->path, "/"))
{
printf("They want the root dir..\n");
@@ -476,7 +475,7 @@
else
{
- ele = ecore_hash_get(file->link_in, com->file_command.files[0]->path);
+ ele = ecore_hash_get(file->link_in, ref->path);
if (ele)
{
printf("Got node..%s/%s\n", ele->path, ele->name);
===================================================================
RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_trash.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- evfs_fs_trash.c 19 Aug 2006 02:58:07 -0000 1.7
+++ evfs_fs_trash.c 20 Aug 2006 04:13:57 -0000 1.8
@@ -52,6 +52,7 @@
static char* next_trash_path;
static char evfs_fs_trash_info[PATH_MAX];
static char evfs_fs_trash_files[PATH_MAX];
+static Ecore_Hash* trash_dir_mapping;
evfs_plugin* posix_plugin;
/*Main file wrappers */
@@ -94,6 +95,25 @@
return newfile;
}
+evfs_filereference* evfs_fs_trash_proxy_create_absolute(evfs_filereference*
ref, char* newdir, char* newsuffix)
+{
+ int size;
+ evfs_filereference* newfile = evfs_filereference_clone(ref);
+
+ /*Make a proxy file, and send this to the posix plugin create*/
+ free(newfile->path);
+
+ size= strlen(newdir) + 1 + strlen(newsuffix) + 1;
+ newfile->path = calloc(size, 1);
+ snprintf(newfile->path, size, "%s/%s", newdir, newsuffix);
+ free(newfile->plugin_uri);
+
+ newfile->plugin_uri = strdup("file");
+ newfile->plugin = posix_plugin;
+
+ return newfile;
+}
+
/*Internal functions*/
char* evfs_fs_trash_filename_get(evfs_filereference* ref)
{
@@ -153,6 +173,9 @@
/*FIXME - this assumes the trash plugin is loaded after posix - not always
true*/
posix_plugin = evfs_get_plugin_for_uri(evfs_server_get(), "file");
+ trash_dir_mapping = ecore_hash_new(ecore_str_hash, ecore_str_compare);
+ ecore_hash_set_free_key(trash_dir_mapping, free);
+
next_trash_file = NULL;
evfs_plugin_functions *functions = calloc(1, sizeof(evfs_plugin_functions));
@@ -292,6 +315,11 @@
free(next_trash_file);
next_trash_file = NULL;
}
+ if (next_trash_path) {
+ free(next_trash_path);
+ next_trash_path = NULL;
+
+ }
next_trash_file = evfs_fs_trash_filename_get(ref);
next_trash_path = evfs_filereference_to_string(ref);
printf("Next trash path is : %s\n", next_trash_path);
@@ -302,11 +330,36 @@
{
evfs_filereference* file_trash;
int fd;
+ char* pos;
+ char* rewrite_parent;
+ char* parent_dir;
+
+ printf("File->path at trash create: '%s'\n", file->path);
+
+ /*Check if this file lives in a directory other than '/'*/
+ if ( (pos = strchr(file->path+1, '/'))) {
+ /*If it does, see if we have a mapping for this dir*/
+ parent_dir = calloc(pos-file->path+1,1 );
+ strncpy(parent_dir, file->path,pos-file->path);
+ parent_dir[pos-file->path] = '\0';
+
+ printf("Rewritten dir: %s\n", parent_dir);
+ rewrite_parent = ecore_hash_get(trash_dir_mapping, parent_dir);
+ printf("Parent dir: %s\n", rewrite_parent);
+ printf("Suffix: '%s'\n", pos+1);
+ file_trash = evfs_fs_trash_proxy_create_absolute(file,
rewrite_parent, pos+1);
- file_trash = evfs_fs_trash_proxy_create(file, next_trash_file);
+ free(parent_dir);
+ } else {
+ printf("Destination path: %s\n", file->path);
+ file_trash = evfs_fs_trash_proxy_create(file, next_trash_file);
- /*printf("Creating new file: %s\n", file_trash->path);*/
+ /*printf("Creating new file: %s\n", file_trash->path);*/
+
+ /*Create the infofile*/
+
evfs_fs_trash_infofile_create(file,next_trash_file,next_trash_path);
+ }
/*Dispatch to posix*/
(*EVFS_PLUGIN_FILE(file_trash->plugin)->functions->evfs_file_create)
(file_trash);
@@ -314,9 +367,6 @@
evfs_cleanup_filereference(file_trash);
- /*Create the infofile*/
- evfs_fs_trash_infofile_create(file,next_trash_file,next_trash_path);
-
free(next_trash_file);
free(next_trash_path);
@@ -329,6 +379,37 @@
int
evfs_file_mkdir(evfs_filereference * file)
{
- printf("evfs_fs_trash.c mkdir - STUB\n");
- return -1;
+ char* pos;
+ char* rewrite_parent;
+ char* parent_dir;
+ evfs_filereference* par;
+
+ /*Check if this file lives in a directory other than '/'*/
+ if ( (pos = strchr(file->path+1, '/'))) {
+ /*If it does, see if we have a mapping for this dir*/
+ parent_dir = calloc(pos-file->path+1,1 );
+ strncpy(parent_dir, file->path,pos-file->path);
+ parent_dir[pos-file->path] = '\0';
+
+ printf("Rewritten dir: %s\n", parent_dir);
+ rewrite_parent = ecore_hash_get(trash_dir_mapping, parent_dir);
+ printf("Parent dir: %s\n", rewrite_parent);
+ printf("Suffix: '%s'\n", pos+1);
+
+ par= evfs_fs_trash_proxy_create_absolute(file,
rewrite_parent, pos+1);
+
+ free(parent_dir);
+ } else {
+ par = evfs_fs_trash_proxy_create(file, next_trash_file);
+
evfs_fs_trash_infofile_create(file,next_trash_file,next_trash_path);
+ }
+
+ /*Dispatch to posix*/
+ (*EVFS_PLUGIN_FILE(par->plugin)->functions->evfs_file_mkdir) (par);
+
+ printf("Trash mkdir: '%s' '%s' '%s'\n", file->path, next_trash_path,
next_trash_file);
+
+ ecore_hash_set(trash_dir_mapping, strdup(file->path),
strdup(par->path));
+
+ evfs_cleanup_filereference(par);
}
===================================================================
RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_vfolder.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- evfs_fs_vfolder.c 14 Aug 2006 10:15:09 -0000 1.13
+++ evfs_fs_vfolder.c 20 Aug 2006 04:13:57 -0000 1.14
@@ -44,7 +44,7 @@
//#define EVFS_PLUGIN_VFOLDER_QUERIES_ID "/Queries"
#define MAX_GROUP_LENGTH 255
-void evfs_dir_list(evfs_client * client, evfs_command * command,
+void evfs_dir_list(evfs_client * client, evfs_filereference* ref,
Ecore_List ** directory_list);
int
@@ -71,18 +71,18 @@
void
-evfs_dir_list(evfs_client * client, evfs_command * command,
+evfs_dir_list(evfs_client * client, evfs_filereference* file,
Ecore_List ** directory_list)
{
Ecore_List *files = ecore_list_new();
evfs_filereference* ref;
char* path;
- path = command->file_command.files[0]->path;
+ path = file->path;
/*We should make this generic - perhaps a plugin system*/
/*FIXME - but this will do for testing*/
- printf("Vfolder listing '%s'..\n", command->file_command.files[0]->path);
+ printf("Vfolder listing '%s'..\n", file->path);
if (!strcmp(path, "/")) {
Ecore_List* keys =
ecore_hash_keys(evfs_server_get()->plugin_vfolder_hash);
@@ -117,7 +117,7 @@
evfs_plugin* plugin =
ecore_hash_get(evfs_server_get()->plugin_vfolder_hash, vfolder_type);
if
(EVFS_PLUGIN_VFOLDER(plugin)->functions->evfs_vfolder_list)
-
(*EVFS_PLUGIN_VFOLDER(plugin)->functions->evfs_vfolder_list)(command->file_command.files[0],
&files);
+
(*EVFS_PLUGIN_VFOLDER(plugin)->functions->evfs_vfolder_list)(file, &files);
}
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs