Enlightenment CVS committal

Author  : chaos
Project : e17
Module  : apps/evfs

Dir     : e17/apps/evfs/src/plugins/file


Modified Files:
        evfs_fs_posix.c evfs_fs_trash.c 


Log Message:
* Some test functions for trash handling

===================================================================
RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_posix.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- evfs_fs_posix.c     21 Apr 2006 15:10:17 -0000      1.1
+++ evfs_fs_posix.c     14 Aug 2006 11:07:48 -0000      1.2
@@ -500,7 +500,7 @@
 int
 evfs_file_create(evfs_filereference * file)
 {
-   //printf ("Creating file '%s'\n", file->path);
+   printf ("Creating file '%s'\n", file->path);
 
    file->fd = open(file->path, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);
 
===================================================================
RCS file: /cvs/e/e17/apps/evfs/src/plugins/file/evfs_fs_trash.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- evfs_fs_trash.c     14 Aug 2006 10:15:09 -0000      1.1
+++ evfs_fs_trash.c     14 Aug 2006 11:07:48 -0000      1.2
@@ -22,6 +22,14 @@
          * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
          * 
          */
+
+/* TODO:
+ *
+ * * Cloning a filereference, and passing it off to evfs_fs_posix, for each 
op, is
+ *   terribly inefficient.  Make a caching engine to avoid this 
+ * 
+ */
+
 #if HAVE_CONFIG_H
 # include <config.h>
 #endif
@@ -39,6 +47,11 @@
 #include <dirent.h>
 #include <Ecore_File.h>
 
+/*All these homedir variables need to be consolidated - TODO*/
+static char evfs_fs_trash_info[PATH_MAX];
+static char evfs_fs_trash_files[PATH_MAX];
+static evfs_plugin* posix_plugin;
+
 /*Main file wrappers */
 int evfs_file_remove(char *src);
 int evfs_file_rename(evfs_client * client, evfs_command * command);
@@ -61,8 +74,12 @@
 evfs_plugin_init()
 {
    printf("Initialising the file plugin..\n");
-   evfs_plugin_functions *functions = calloc(1, sizeof(evfs_plugin_functions));
 
+   snprintf(evfs_fs_trash_info, sizeof(evfs_fs_trash_info), "%s/.Trash/info", 
getenv("HOME"));
+   snprintf(evfs_fs_trash_files, sizeof(evfs_fs_trash_files), 
"%s/.Trash/files", getenv("HOME"));
+   posix_plugin = evfs_get_plugin_for_uri(evfs_server_get(), "file");
+   
+   evfs_plugin_functions *functions = calloc(1, sizeof(evfs_plugin_functions));
    functions->evfs_client_disconnect = &evfs_client_disconnect;
 
    /*functions->evfs_file_remove = &evfs_file_remove;
@@ -120,8 +137,12 @@
 int
 evfs_file_close(evfs_filereference * file)
 {
-       printf("evfs_fs_trash.c close - STUB\n");
-       return -1;      
+       if (file->plugin) 
+               return 
(*EVFS_PLUGIN_FILE(posix_plugin)->functions->evfs_file_close) (file);
+       else
+               printf("Trash file not opened with trash plugin\n");    
+
+       return 0;
 }
 
 int
@@ -142,15 +163,37 @@
 int
 evfs_file_write(evfs_filereference * file, char *bytes, long size)
 {
-       printf("evfs_fs_trash.c write - STUB\n");
-       return -1;
+       if (file->plugin) {
+               return 
(*EVFS_PLUGIN_FILE(posix_plugin)->functions->evfs_file_write) (file, bytes, 
size);
+       } else
+               printf("Trash file not opened with trash plugin\n");
 }
 
 int
 evfs_file_create(evfs_filereference * file)
-{
-       printf("evfs_fs_trash.c create (%s) - STUB\n", file->path);
-       return -1;
+{      
+       evfs_filereference* file_trash = evfs_filereference_clone(file);
+       int fd;
+       int size;
+       
+       free(file_trash->path);
+       size= strlen(evfs_fs_trash_files) + strlen(file->path) +2;
+       file_trash->path = calloc(size, 1);
+       snprintf(file_trash->path, size, "%s/%s", evfs_fs_trash_files, 
file->path);
+       free(file_trash->plugin_uri);
+       file_trash->plugin_uri = strdup("file");
+       file_trash->plugin = posix_plugin;
+
+       printf("Creating trash file: %s\n", file_trash->path);
+
+       (*EVFS_PLUGIN_FILE(file_trash->plugin)->functions->evfs_file_create) 
(file_trash);
+       file->fd = file_trash->fd;      
+
+       printf("Trash file fd: %d\n", file->fd);
+       
+       evfs_cleanup_filereference(file_trash);
+       
+       return file->fd;
 }
 
 int



-------------------------------------------------------------------------
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
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to