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?
The most common use of st_mode is to determine whether the name refers to a file or to a directory. That could be replaced by e.g. G_is_file() and G_is_directory(). 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 Windows. > >> 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. Regardless of whatever utility functions we create, I think that we still need to provide a portable stat() interface which handles LFS. -- Glynn Clements <[email protected]> _______________________________________________ grass-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-dev
