home *** CD-ROM | disk | FTP | other *** search
-
- (*
- * remove_path - remove pathname prefix from a filename
- *
- *)
-
- function remove_path(name: anystring): anystring;
- var
- n: anystring;
- i: integer;
- begin
- n := '';
- for i := 1 to length(name) do
- case name[i] of
- ':','\':
- n := ''
- else
- n := n + name[i];
- end;
-
- remove_path := n;
- end;
-
-
- (*
- * path_only - return pathname prefix from a filename
- *
- *)
-
- function path_only(name: anystring): anystring;
- var
- n: anystring;
- i: integer;
-
- begin
-
- {scan backwards looking for the last : or \ in the pathname}
- n := name;
- i := length(n);
- while (i > 0) and (name[i] <> ':') and (name[i] <> '\') do
- dec(i);
-
- n[0] := chr(i);
-
- {add a trailing "\" if needed}
- if (length(n) > 2) and (n[length(n)] <> '\') then
- n := n + '\';
-
- path_only := n;
- end;
-
-
- (*
- * remove_ext - remove filename .ext
- *
- *)
-
- function remove_ext(name: anystring): anystring;
- var
- n: anystring;
- i: integer;
- begin
- n := name;
- i := length(n);
- while (i > 0) and (name[i] <> '.') do
- dec(i);
-
- if name[i] = '.' then
- n[0] := chr(i-1);
-
- remove_ext := n;
- end;
-
-
- (*
- * ext_only - return only the ext portion of a filename
- *
- *)
-
- function ext_only(name: anystring): anystring;
- var
- i: integer;
- begin
- i := length(name);
- while (i > 0) and (name[i] <> '.') do
- dec(i);
-
- if name[i] = '.' then
- ext_only := copy(name,i+1,99)
- else
- ext_only := '';
- end;
-
- (*
- * dir_only - return the directory portion of a filename. same
- * as path_only except without the trailing "\".
- *)
-
- function dir_only(name: anystring): anystring;
- var
- n: anystring;
-
- begin
- n := path_only(name);
- if n[length(n)] = '\' then
- dec(n[0]);
-
- dir_only := n;
- end;
-
-