Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dirfunctions.md « doc - github.com/torch/paths.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 51584bb550bbd3a1a650fefd1263c13314e62ccd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<a name="paths.dirs.dok"></a>
## Directory Functions ##

The following functions can be used
to examine directory contents or manipulate directories.

<a name="paths.dir"></a>
### paths.dir(dname) ###

Return a table containing the files and directories in directory `dname`.
This function return `nil` if the specified directory does not exists. 
For linux, this includes the `.` and `..` directories.

<a name="paths.files"></a>
### paths.files(dname [, include]) ###

Returns an iterator over the files and directories located in directory `dname`.
For linux, this includes the `.` and `..` directories. 
This can be used in *__for__* expression as shown below:

```lua
for f in paths.files(".") do
   print(f)
end
```

Optional argument `include` is either a function or a string used to 
determine which files are to be included. The function takes the filename 
as argument and should return true if the file is to be included. 
When a string is provided, the following function is used :

```lua
function(file) 
   return file:find(f) 
end
```

Files and directories of sub-folders aren't included.

<a name="paths.iterdirs"></a>
### paths.iterdirs(dname) ###

Returns an iterator over the directories located in directory `dname`.
This can be used in *__for__* expression as shown below:

```lua
for dir in paths.iterdirs(".") do
   print(dir)
end
```

Directories of sub-folders, and the `.` and `..` folders aren't included.

<a name="paths.iterdirs"></a>
### paths.iterfiles(dname) ###

Returns an iterator over the files (non-directories) located in directory `dname`.
This can be used in *__for__* expression as shown below:

```lua
for file in paths.iterfiles(".") do
   print(file)
end
```

Files of sub-folders, and the `.` and `..` folders aren't included.

<a name="paths.mkdir"></a>
### paths.mkdir(s) ###

Create a directory.
Returns `true` on success.

<a name="paths.rmdir"></a>
### paths.rmdir(s) ###

Delete an empty directory.
Returns `true` on success.

<a name="paths.rmall"></a>
### paths.rmall(s, y) ###

Recursively delete file or directory `s` and its contents.
Argument `y` must be string `"yes"`
Returns `true` on success.