? src/lock.c ? src/lock.h Index: src/Makefile.am =================================================================== RCS file: /cvs/gnome/gnumeric/src/Makefile.am,v retrieving revision 1.288 diff -u -r1.288 Makefile.am --- src/Makefile.am 8 Jul 2002 17:06:29 -0000 1.288 +++ src/Makefile.am 15 Jul 2002 14:16:35 -0000 @@ -261,7 +261,9 @@ xml-io.h \ xml-io-version.h \ xml-io-autoft.c \ - xml-io-autoft.h + xml-io-autoft.h \ + lock.c \ + lock.h # TODO : split the bonobo and corba tests one day GNUMERIC_CORBA = \ Index: src/file.c =================================================================== RCS file: /cvs/gnome/gnumeric/src/file.c,v retrieving revision 1.112 diff -u -r1.112 file.c --- src/file.c 8 Jul 2002 17:06:30 -0000 1.112 +++ src/file.c 15 Jul 2002 14:16:35 -0000 @@ -26,6 +26,7 @@ #include "workbook-view.h" #include "workbook.h" #include "gutils.h" +#include "lock.h" #include "error-info.h" #include @@ -195,6 +196,10 @@ { g_return_if_fail (IS_GNUM_FILE_OPENER (fo)); g_return_if_fail (GSF_IS_INPUT (input)); + if (is_locked(file_name)) { + gnumeric_io_error_info_set(io_context, error_info_new_str("File is in use!")); + return; + } GNUM_FILE_OPENER_METHOD (fo, open) (fo, io_context, wbv, input); } Index: src/workbook-view.c =================================================================== RCS file: /cvs/gnome/gnumeric/src/workbook-view.c,v retrieving revision 1.98 diff -u -r1.98 workbook-view.c --- src/workbook-view.c 8 Jul 2002 17:06:30 -0000 1.98 +++ src/workbook-view.c 15 Jul 2002 14:16:35 -0000 @@ -43,6 +43,7 @@ #include "position.h" #include "cell.h" #include "io-context.h" +#include "lock.h" #include #include @@ -586,9 +587,14 @@ if (fs == NULL) gnumeric_io_error_save (io_context, _("Default file saver is not available.")); - else - gnum_file_saver_save (fs, io_context, wbv, wb->filename); - + else { + if(is_locked(wb->filename)) + gnumeric_io_error_save(io_context, + _("File is in use!")); + else + gnum_file_saver_save (fs, io_context, wbv, wb->filename); + } + error = gnumeric_io_error_occurred (io_context); if (error) gnumeric_io_error_display (io_context); Index: src/workbook.c =================================================================== RCS file: /cvs/gnome/gnumeric/src/workbook.c,v retrieving revision 1.554 diff -u -r1.554 workbook.c --- src/workbook.c 14 Jul 2002 02:11:23 -0000 1.554 +++ src/workbook.c 15 Jul 2002 14:16:36 -0000 @@ -33,6 +33,7 @@ #include "file.h" #include "io-context.h" #include "gutils.h" +#include "lock.h" #include "gnm-marshalers.h" #include "style-color.h" @@ -126,6 +127,11 @@ Workbook *wb = WORKBOOK (wb_object); GList *sheets, *ptr; + /* BV 14/12/2001 + * Add file locking to Gnumeric + */ + relinquish_lock(workbook_get_filename(wb)); + wb->priv->during_destruction = TRUE; if (wb->file_saver != NULL) { @@ -478,11 +484,21 @@ g_return_val_if_fail (wb != NULL, FALSE); g_return_val_if_fail (name != NULL, FALSE); - if (wb->filename) + if (wb->filename) { + /* BV 14/12/2001 + * Add file locking to gnumeric + */ + relinquish_lock(wb->filename); g_free (wb->filename); + } wb->filename = g_strdup (name); base_name = g_basename (name); + + /* BV 14/12/2001 + * Add file locking to gnumeric + */ + if( acquire_lock(wb->filename) == FALSE ) { return FALSE; } WORKBOOK_FOREACH_CONTROL (wb, view, control, wb_control_title_set (control, base_name););