home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / xc212os2.zip / DEF / filename.def next >
Text File  |  1994-12-22  |  2KB  |  71 lines

  1. (* Copyright (c) 1994 xTech Ltd, Russia. All Rights Reserved. *)
  2. DEFINITION MODULE FileName; (* Ned 15-Feb-94. *)
  3.  
  4. (* File name procedures.
  5.  
  6.    File name consists of three parts:
  7.         - directory
  8.         - name
  9.         - extensions.
  10.  
  11.    The given procedures allow to parse file name and to construct
  12.    file name from its parts.
  13.  
  14.    All the procedures that construct a string value (Get, GetDir,
  15.    GetName,  GetExt,  Convert, Create), have the property that if
  16.    the  length  of  the  constructed  string  value  exceeds  the
  17.    capacity  of  the  variable  parameter,  a  truncated value is
  18.    assigned,  while if the length of the constructed string value
  19.    is  less than the capacity of the variable parameter, a string
  20.    terminator is appended.
  21. *)
  22.  
  23. TYPE
  24.   Format = RECORD
  25.     ok: BOOLEAN;               (* result *)
  26.     dirPos, dirLen : CARDINAL; (* directory position and length *)
  27.     namePos,nameLen: CARDINAL; (* name position and length *)
  28.     extPos, extLen : CARDINAL; (* extension position and length *)
  29.   END;
  30.  
  31. (*----------------------------------------------------------------*)
  32.  
  33. PROCEDURE GetFormat(str: ARRAY OF CHAR; VAR f: Format);
  34. (* Returns the format of the string.
  35.    The values of *Pos, *Len fields are undefined
  36.    if f.ok=FALSE.
  37. *)
  38.  
  39. (* Get* procedures does not provide conversions
  40.   (ie. no case chanegs or reductions).
  41. *)
  42.  
  43. PROCEDURE GetDir (fname: ARRAY OF CHAR; VAR dir: ARRAY OF CHAR);
  44. PROCEDURE GetName(fname: ARRAY OF CHAR; VAR name: ARRAY OF CHAR);
  45. PROCEDURE GetExt (fname: ARRAY OF CHAR; VAR ext: ARRAY OF CHAR);
  46.  
  47. PROCEDURE Get(fname: ARRAY OF CHAR;
  48.    VAR dir,name,ext: ARRAY OF CHAR);
  49.  
  50. (*----------------------------------------------------------------*)
  51.  
  52. PROCEDURE Convert(str: ARRAY OF CHAR; VAR fname: ARRAY OF CHAR);
  53. (* Converts string (dir,name,ext) to file name
  54.   according to the conventions of the underlying file system.
  55. *)
  56.  
  57. PROCEDURE ConvertExt(VAR ext: ARRAY OF CHAR);
  58. (* Converts extension according to the conventions of
  59.   the underlying file system.
  60. *)
  61.  
  62. PROCEDURE Length(dir,name,ext: CARDINAL): CARDINAL;
  63. (* Returns estimated length, which is greater or equal
  64.    then generated file name length after Create call.
  65. *)
  66.  
  67. PROCEDURE Create(dir,name,ext: ARRAY OF CHAR;
  68.                     VAR fname: ARRAY OF CHAR);
  69.  
  70. END FileName.
  71.