-
Notifications
You must be signed in to change notification settings - Fork 4
/
path.functions
84 lines (60 loc) · 1.61 KB
/
path.functions
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
# This file is part of shellfire core. It is subject to the licence terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/core/master/COPYRIGHT. No part of shellfire core, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
# Copyright © 2014-2015 The developers of shellfire core. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/shellfire-dev/core/master/COPYRIGHT.
core_path_isReadableFilePath()
{
local filePath="$1"
if [ ! -e "$filePath" ]; then
return 1
fi
if [ ! -f "$filePath" ]; then
return 1
fi
if [ -r "$filePath" ]; then
return 0
fi
return 1
}
core_path_isReadableNonEmptyFilePath()
{
local filePath="$1"
core_path_isReadableFilePath "$filePath"
if [ -s "$filePath" ]; then
return 0
fi
return 1
}
core_path_isReadableNonEmptyExecutableFilePath()
{
local filePath="$1"
core_path_isReadableNonEmptyFilePath "$filePath"
if [ -x "$filePath" ]; then
return 0
fi
return 1
}
core_path_isReadableAndSearchableFolderPath()
{
local folderPath="$1"
if [ ! -e "$folderPath" ]; then
return 1
fi
if [ ! -d "$folderPath" ]; then
return 1
fi
if [ ! -r "$folderPath" ]; then
return 1
fi
if [ -x "$folderPath" ]; then
return 0
fi
return 1
}
core_path_isReadableAndSearchableAndWritableFolderPath()
{
core_path_isReadableAndSearchableFolderPath "$1"
local folderPath="$1"
if [ -w "$folderPath" ]; then
return 0
fi
return 1
}