Enlightenment CVS committal

Author  : lordchaos
Project : e17
Module  : apps/evfs

Dir     : e17/apps/evfs/src/plugins


Modified Files:
        evfs_fs_posix.c evfs_fs_samba.c 


Log Message:
* Drastic changes allowing a more generic VFS structure, and also allowing file 
system operations between different file systems. This still needs a lot of 
work, but a basic 'copy' function is already working
* Fixed the non-generic smb-stat problem.  This will still be an issue with 
multiple-client locking, but we'll deal with that later

===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/plugins/evfs_fs_posix.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -3 -r1.12 -r1.13
--- evfs_fs_posix.c     8 Oct 2005 01:53:25 -0000       1.12
+++ evfs_fs_posix.c     16 Oct 2005 10:09:05 -0000      1.13
@@ -46,8 +46,13 @@
 
 int evfs_monitor_start(evfs_client* client, evfs_command* command);
 int evfs_monitor_stop(evfs_client* client, evfs_command* command);
-
-int evfs_file_stat(evfs_client* client, evfs_command* command);
+int evfs_file_open(evfs_filereference* file);
+int evfs_file_close(evfs_filereference* file);
+int evfs_file_stat(evfs_command* command, struct stat* file_stat);
+int evfs_file_seek(evfs_filereference* file, long offset, int whence);
+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);
 
 
 /*Internal functions*/
@@ -79,6 +84,13 @@
        functions->evfs_monitor_start = &evfs_monitor_start;
        functions->evfs_monitor_stop = &evfs_monitor_stop;
        functions->evfs_file_stat = &evfs_file_stat;
+       functions->evfs_file_open = &evfs_file_open;
+       functions->evfs_file_close = &evfs_file_close;
+       
+       functions->evfs_file_seek = &evfs_file_seek;
+       functions->evfs_file_read = &evfs_file_read;
+       functions->evfs_file_write = &evfs_file_write;
+       functions->evfs_file_create = &evfs_file_create;
        return functions;
 
        
@@ -258,19 +270,86 @@
 }
 
 
-int evfs_file_stat(evfs_client* client, evfs_command* command) {
-       struct stat file_stat;
+int evfs_file_stat(evfs_command* command, struct stat* file_stat) {
 
        printf("Getting file stat...\n");
 
-       stat(command->file_command.files[0]->path, &file_stat);
+       stat(command->file_command.files[0]->path, file_stat);
+
+       printf("File size: %d\n", file_stat->st_size);
+
+       
+}
+
+
+
+int evfs_file_open(evfs_filereference* file) {
+       printf("Open file '%s'\n", file->path);
+
+       int fd = open(file->path, O_RDONLY);
+       printf("Assigned fd %d\n", fd);
+       file->fd = fd;
+
 
-       printf("File size: %d\n", file_stat.st_size);
+       return 0;
+}
+
+int evfs_file_close(evfs_filereference* file) {
+       int res;
+       
+       printf("Close file '%s'\n", file->path);
 
-       evfs_stat_event_create(client, command, &file_stat);
+       res = close(file->fd);
+       file->fd = 0;
+       
+       return 0;
 }
 
+int evfs_file_seek(evfs_filereference* file, long offset, int whence) {
+       printf ("Seek in file '%s' forward by '%d'\n", file->path, offset);
 
+       lseek(file->fd, offset, SEEK_SET);
+
+       return 0;
+}
+
+int evfs_file_read(evfs_filereference* file, char* bytes, long size) {
+       int bytes_read;
+       
+       printf("Reading %d bytes from %s\n", size, file->path);
+       
+       bytes_read = read(file->fd, bytes, size);
+
+       if (bytes_read) {
+               //bytes[bytes_read] = '\0';
+               //printf ("Read '%s'\n", bytes);
+       } else {
+               return 1;
+       }
+
+       return 0;
+       
+}
+
+int evfs_file_write(evfs_filereference* file, char* bytes, long size) {
+       ssize_t i;
+       
+       printf("Writing %d bytes for %s\n", size, file->path);
+       
+
+       i = write(file->fd, bytes, size);
+       printf("Wrote %d bytes\n", i);
+
+       return 0;
+}
+
+int evfs_file_create(evfs_filereference* file) {
+       printf ("Creating file '%s'\n", file->path);
+
+       file->fd = open(file->path, O_CREAT | O_TRUNC | O_RDWR , S_IRUSR | 
S_IWUSR);
+
+       return 0;
+}
 
 
 
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/evfs/src/plugins/evfs_fs_samba.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- evfs_fs_samba.c     11 Oct 2005 05:33:47 -0000      1.6
+++ evfs_fs_samba.c     16 Oct 2005 10:09:05 -0000      1.7
@@ -40,12 +40,20 @@
 #include <Ecore_File.h>
 #include <libsmbclient.h>
 
-static struct stat file_stat;
+//static struct stat file_stat;
 int smbc_remove_unused_server(SMBCCTX * context, SMBCSRV * srv);
 static SMBCCTX *smb_context = NULL;
 
 static void smb_evfs_dir_list(evfs_client* client, evfs_command* command);
-static void smb_evfs_file_stat(evfs_client* client, evfs_command* command);
+
+
+int smb_evfs_file_stat(evfs_command* command, struct stat* file_stat);
+int evfs_file_open(evfs_filereference* file);
+int evfs_file_close(evfs_filereference* file);
+int evfs_file_seek(evfs_filereference* file, long offset, int whence);
+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);
 
 
 
@@ -94,9 +102,12 @@
        printf("Initialising the samba plugin..\n");
        evfs_plugin_functions* functions = 
malloc(sizeof(evfs_plugin_functions));
        functions->evfs_dir_list = &smb_evfs_dir_list;
-       /*functions->evfs_file_remove= &evfs_file_remove;
-       functions->evfs_monitor_start = &evfs_monitor_start;
-       functions->evfs_monitor_stop = &evfs_monitor_stop;*/
+       functions->evfs_file_open = &evfs_file_open;
+       functions->evfs_file_close = &evfs_file_close;
+       //functions->evfs_file_seek = &evfs_file_seek;
+       //functions->evfs_file_read = &evfs_file_read;
+       functions->evfs_file_write = &evfs_file_write;
+       functions->evfs_file_create = &evfs_file_create;
        functions->evfs_file_stat = &smb_evfs_file_stat;
        printf("Samba stat func at '%p'\n", &smb_evfs_file_stat);
 
@@ -128,25 +139,25 @@
        return "smb";
 }
 
-static void smb_evfs_file_stat(evfs_client* client, evfs_command* command) {
+int smb_evfs_file_stat(evfs_command* command, struct stat* file_stat) {
        
        int err = 0;
        int fd = 0;
-       char dir[1024];
+       char dir[128];
        //struct stat* file_stat = calloc(1,sizeof(struct stat));
        
-       SMBCFILE* file= NULL;
        
        sprintf(dir,"smb:/%s", command->file_command.files[0]->path);
        printf("Getting stat on file '%s'\n", dir);
 
-       err = smb_context->stat(smb_context, dir, &file_stat);
+       err = smb_context->stat(smb_context, (const char*)dir, file_stat);
        printf("Returned error code: %d\n", err);
-       evfs_stat_event_create(client, command, &file_stat);
-       printf("File size: %d\n", file_stat.st_size);
+       printf("File size: %d\n", file_stat->st_size);
        
        printf("Returning to caller..\n");
 
+       return 0;
+
 }
 
 static void smb_evfs_dir_list(evfs_client* client, evfs_command* command) {
@@ -196,3 +207,44 @@
        evfs_list_dir_event_create(client, command, files);
 
 }
+
+
+int evfs_file_open(evfs_filereference* file) {
+       char dir_path[1024];
+       snprintf(dir_path,1024,"smb:/%s", file->path);
+
+       printf("Opening file '%s' in samba\n");
+
+       
+
+       return 0;
+}
+
+int evfs_file_close(evfs_filereference* file) {
+       printf ("SMB close: closing\n");
+
+       smb_context->close(smb_context, file->fd_p);
+
+       return 0;
+}
+
+int evfs_file_write(evfs_filereference* file, char* bytes, long size) {
+       ssize_t i;
+       
+       printf ("SMB write: %d bytes\n", size);
+
+       i = smb_context->write(smb_context, file->fd_p, bytes, size);
+       printf("Wrote %d bytes\n", i);
+
+       return 0;
+}
+
+int evfs_file_create(evfs_filereference* file) {
+       char dir_path[1024];
+       snprintf(dir_path,1024,"smb:/%s", file->path);
+
+       printf ("SMB File create: %s\n", dir_path);
+
+       file->fd_p = smb_context->open(smb_context, dir_path, O_CREAT | O_TRUNC 
| O_RDWR , S_IRUSR | S_IWUSR);
+       return 0;
+}




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to