Merge /u/jsb1685/fgdata/ branch next into next
https://sourceforge.net/p/flightgear/fgdata/merge-requests/161/
This commit is contained in:
commit
a83b64b689
1 changed files with 21 additions and 0 deletions
21
Nasal/io.nas
21
Nasal/io.nas
|
@ -22,6 +22,27 @@ var dirname = func(path) {
|
|||
substr(path, 0, size(path) - size(basename(path)));
|
||||
};
|
||||
|
||||
var is_directory = func(path) {
|
||||
var tmp = stat(path);
|
||||
if (tmp != nil and tmp[11] == "dir") return 1;
|
||||
else return 0;
|
||||
};
|
||||
|
||||
# <path> the path that should be searched for subdirectories
|
||||
# returns a vector of subdirectory names
|
||||
var subdirectories = func(path) {
|
||||
if (!is_directory(path))
|
||||
return;
|
||||
var list = subvec(directory(path), 2);
|
||||
var subdirs = [];
|
||||
foreach (var entry; list) {
|
||||
if (is_directory(path~"/"~entry)) {
|
||||
append(subdirs, entry);
|
||||
}
|
||||
}
|
||||
return subdirs;
|
||||
}
|
||||
|
||||
# include(<filename>)
|
||||
#
|
||||
# Loads and executes a Nasal file in place. The file is searched for in the
|
||||
|
|
Loading…
Add table
Reference in a new issue