Re: [Bug 161797] Save as... fails in win32 when curdir is on server



On Mon, 2005-01-03 at 23:28 +0000, Tor Lillqvist wrote:
> Owen Taylor writes:
>  > Can we use/extend the GtkFileSystem abstraction here rather than
>  > introducing #ifdef's?
> 
> You mean like this: Adding the methods:
> 
>   int  (*path_compare) (GtkFileSystem *file_system,
> 			const gchar   *path1,
> 			const gchar   *path2);
>   char (*get_desktop)  (GtkFileSystem *file_system);
> 
> to the GtkFileSystemIface struct, and adding the functions:
> 
> int      gtk_file_system_path_compare    (GtkFileSystem     *file_system,
> 					  const GtkFilePath *path1,
> 					  const GtkFilePath *path2);
> 
> GtkFilePath *gtk_file_system_get_desktop (GtkFileSystem     *file_system);

For get_desktop(), yes. (const GtkFilePath *, I think). For file path
comparison, less sure.

> But what should be done with the gtk_file_path_compare(path1,path2)
> macro? Should that be made into a function in gtkfilesystem.c that
> uses an internal static GtkFileSystem object (of either the "Unix" or
> "Win32" variant) and calls gtk_file_system_path_compare()? Like this:

Hmm. Keeping GtkFilePath small and light is important. In the past
I considered allowing virtualization of GtkFilePath by doing
something like:

 void
 gtk_file_path_free (path)
 {
    g_free ((char *)path - sizeof(GtkFilePathClass *);
 }

 void
 gtk_file_path_compare (path1, path2)
 {
    GtkFilePathClass *class = (GtkFilePathClass **)((char *)path -
GtkFilePathClass *);
    if (class && class->compare)
       return class->compare (path1, path2); 
    else
       return strcmp (path1, path2);
 }

But simply making path comparison a filesystem vfunction might be
simpler. One question before we go to far into solving this is when
is the current comparison a problem? When are we comparing a filename
in indeterminate case to a filename in the casing from the filesystem?

> int
> gtk_file_path_compare (const GtkFilePath *path1,
>                        const GtkFilePath *path2)
> {
>   static GtkFileSystem *fs = NULL;
> 
>   if (fs == NULL)
>     {
> #ifdef G_OS_WIN32
>       fs = gtk_file_system_win32_new ();
> #else
>       fs = gtk_file_system_unix_new ();
> #endif
>     }
> 
>   return gtk_file_system_path_compare (fs, path1, path2);
> }
>
> Why BTW can there be several instances of GtkFileSystemUnix (and
> GtkFileSystemWin32)? Shouldn't these ideally be singletons? Or am I
> (very likely) missing something?

I suppose they could be singletons, but that would require
a fair bit of reworking. Having a single file system object per 
file chooser also gives some limits to caching and hope that
memory might be eventually freed.

Regards,
				Owen

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]