1 Exception utilities
2 Number utilities
3 String utilities
4 Bytes utilities
5 Symbol utilities
6 List utilities
7 PLT 4x hash utilities
8 PLT 3x hash utilities
9 URL utilities
10 Contract utilities
11 File and path utilities
12 Parameter utilities
13 Syntax utilities
14 SRFI19 time utilities
15 Scribble utilities
16 Generators
17 Generators (short names)
18 Pipelines
19 Write-through cache
20 Yieldable procedures
21 Debugging tools
22 Profiling tools
23 Logging tools
On this page:
make-directory-tree
make-non-conflicting-filename
make-non-conflicting-path
read-file->string
concatenate-files
Version: 4.0.0.1

 

11 File and path utilities

 (require (planet untyped/unlib/file))

Utilities for manipulating files and paths.

(make-directory-tree tree)  void?

  tree : folders-spec

Creates a directory tree in the current directory that matches tree, which is a tree of strings of type folders-spec:

folders-spec ::= (listof folder-spec)

folder-spec  ::= string folders-spec

tree-spec For example, the code:

  (make-directory-tree '("a" ("b" "c" ("d"))))

would create the directory tree:

/a

/a/b

/a/c

/a/c/d

Any existing directories in the tree are left intact.

(make-non-conflicting-filename

 

path

 

 

 

 

 

 

filename)

 

 

string?

  path : (U path? string?)

  filename : string?

Returns a filename that is guaranteed to not conflict with the names of any files in path. For example:

  (make-non-conflicting-filename (string->path "mydir") "myfile.txt")

would return:

(make-non-conflicting-path path filename)  path?

  path : (U path? string?)

  filename : string?

Like make-non-conflicting-filename but returns:

  (build-path path (make-non-conflicting-filename path filename))

(read-file->string file)  string?

  file : (U path? string?)

Reads the contents of file into a string. See the port.plt collection on PLaneT for more advanced functions along these lines.

(concatenate-files dest sources)  void?

  dest : (U path? string?)

  sources : (listof (U path? string?))

Concatenates (appends) the contents of sources and writes the result to dest.