fnames

lib
Synopsis

  inherit "/obj/lib/fnames";

  #include "/obj/lib/fnames.h"
  #include "/obj/lib/fnames_p.h"   for the prototypes


string basepath (string fname, void|int what)

  Split a normalized filename (beginning with "/") into path (with
  trailing "/") and basename. Return either the path (what == 0) or
  the basename (what != 0).


mixed *parse_fname (string src, void|object pl)

 Expand <src> to a complete filename by calling pl->get_path() (if pl isn't
 given, it defaults to this_player()) and return an array with following
 information:

   [NAME] (str): the complete pathname of srcname.
   [PATH] (str): the pure path of [0] with trailing "/" (may be just "/") .
   [BASE] (str): the basename of [0] (may be "").
   [SIZE] (int): file_size([0]) or FILE_WILD if the basename contains
                 wildcards ('*'). If it's FILE_NA, the full name is invalid.
   [PSIZE](int): file_size([1]); if it's FILE_NA, the full name is invalid.
   [BSIZE](int): file_size([2]) if given and not wildcarded, else undefined.

 The special constants used for SIZE,PSIZE,BSIZE are:

   FILE_NA   == -1 : File doesn't exists or is not accessible.
   FILE_DIR  == -2 : File is a directory.
   FILE_WILD == -3 : Filename contains wildcards ('*').

 FILE_NA and FILE_DIR are the ones also returned by efun file_size().


string _tackon (string name, string path)

  Returns <path>+<name>.
  This is for internal use of get_flist() only.


string *get_flist (mixed *fdsc, void|int mode) {

  get_flist() takes the return of parse_fname() and returns an array
  of the (base)names of matching files (which may also be empty if no files
  are found).

  If parse_fname() got an illegal file-designation, get_flist() returns 0.

  <mode> defines how the output of get_flist() looks like. The several
  single modes may be or'ed (with |) as needed.
    GF_EXT : The simul_efun get_dir_ext() is used instead of get_dir(),
             so that the filetype is automagically flagged.
    GF_LONG: Every file in the resulting array includes it's full path.
    GF_SIZE: after each filename follows it's size.
    GF_DATE: after each filename (and opt. size) follows it's date.

  Note that get_flist("/dir/") lists the full dir, whereas get_flist("/dir/*")
  may stumble over one file "/dir/*".


string f_name (mixed arg, void|int pointc)

  Find the real filename (opt. with trailing '.c' if <pointc> is nonzero) 
  of an object.
  <arg> may be the object itself, or already it's object_name().
  The name is not checked for validity, though.