[GRASS-dev] diglib test.c fails on 64bit win
markus.metz.giswork at googlemail.com
Fri May 21 04:09:03 EDT 2010
Glynn Clements wrote:
> Markus Metz wrote:
>> At least clean_temp, d.font, g.mkfontcap, g.access need stat(), no way
>> to replace that with a more portable version to get time and/or mode?
> g.access actually uses the permissions. G_recursive_copy() reads the
> permissions to copy them to the new file. G_rc_path() checks that the
> permissions are sufficient. No idea how well any of this works on
(Get someone to) test...
>> >> In these cases, stat() could be
>> >> replaced in trunk with
>> >> curr_pos = G_ftell(fp)
>> >> G_fseek(fp, 0, SEEK_END)
>> >> filesize = G_ftell(fp)
>> >> G_fseek(fp, curr_pos, SEEK_SET)
>> >> something like that is done e.g. in lib/vector/Vlib/open.c (all branches)
>> > That's an option if the file is already open (and has the advantage
>> > that it works with open files on Windows, which stat() doesn't; see
>> > #1006). I'd be inclined to add a version using a file descriptor.
>> Leave all that to a new "off_t G_file_size()" ?
> That's fine if the file is open (or would be opened before the size is
> required). There may be cases where code needs the size of a file but
> has reasons to avoid opening it.
Hm, either have "off_t G_file_size(FILE *fp, char *path)" that uses
G_fseek/G_ftell if fp != NULL, otherwise stat(), needs to be called
correctly, or have two functions like "off_t G_file_size_fp(FILE *fp)"
and "off_t G_file_size_name(char *path)" ? And you thought about a
version using file descriptor, something like "off_t
> Regardless of whatever utility functions we create, I think that we
> still need to provide a portable stat() interface which handles LFS.
Haven't you given the answer with
#if defined(__MINGW32__) && defined(_FILE_OFFSET_BITS) &&
_FILE_OFFSET_BITS == 64
/* other defines */
#define stat stat64
#define fstat fstat64
typedef struct _stati64 STRUCT_STAT;
typedef struct stat STRUCT_STAT;
Additionally, we would need to make sure that stat() is only called on
not (yet) opened files, going through the code and verifying each
usage of stat().
More information about the grass-dev