Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10433379
directories.go
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
929 B
Subscribers
None
directories.go
View Options
package
config
import
(
"os"
"path/filepath"
"github.com/writeas/writeas-cli/fileutils"
"github.com/writeas/writeas-cli/log"
)
// UserDataDir returns a platform specific directory under the user's home
// directory
func
UserDataDir
(
dataDirName
string
)
string
{
return
filepath
.
Join
(
parentDataDir
(),
dataDirName
)
}
func
dataDirExists
(
dataDirName
string
)
bool
{
return
fileutils
.
Exists
(
dataDirName
)
}
func
createDataDir
(
dataDirName
string
)
error
{
return
os
.
Mkdir
(
dataDirName
,
0700
)
}
// DirMustExist checks for a directory, creates it if not found and either
// panics or logs and error depending on the status of Debug
func
DirMustExist
(
dataDirName
string
)
{
// Ensure we have a data directory to use
if
!
dataDirExists
(
dataDirName
)
{
err
:=
createDataDir
(
dataDirName
)
if
err
!=
nil
{
if
Debug
()
{
panic
(
err
)
}
else
{
log
.
Errorln
(
"Error creating data directory: %s"
,
err
)
return
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 20, 3:17 AM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3136698
Attached To
rWCLI writeas-cli
Event Timeline
Log In to Comment