aboutsummaryrefslogtreecommitdiffstats
path: root/src/i_insert.go
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-04-15 20:20:20 +0200
committerJoe <rbo@gmx.us>2024-04-15 20:20:20 +0200
commitb33dca29fdf3ccefd16412589feefd66b735a534 (patch)
tree35f58b8e433e77ec1ab2dcf7381f80c8f9dcfbf9 /src/i_insert.go
parentprogress (diff)
downloadhardflip-b33dca29fdf3ccefd16412589feefd66b735a534.tar.gz
hardflip-b33dca29fdf3ccefd16412589feefd66b735a534.tar.bz2
hardflip-b33dca29fdf3ccefd16412589feefd66b735a534.tar.xz
hardflip-b33dca29fdf3ccefd16412589feefd66b735a534.tar.zst
hardflip-b33dca29fdf3ccefd16412589feefd66b735a534.zip
up
Diffstat (limited to '')
-rw-r--r--src/i_insert.go37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/i_insert.go b/src/i_insert.go
index 637f01f..5bc959c 100644
--- a/src/i_insert.go
+++ b/src/i_insert.go
@@ -87,7 +87,7 @@ func i_insert_format_filename(name, path string) string {
}
func i_insert_abs_files(insert *HostNode) {
- files := [3]*string{
+ files := []*string{
&insert.Priv,
&insert.Jump.Priv,
&insert.RDPFile,
@@ -105,6 +105,19 @@ func i_insert_abs_files(insert *HostNode) {
*v, _ = filepath.Abs(*v)
}
}
+ for k, v := range insert.Drive {
+ if len(v) > 0 {
+ if (v)[0] == '~' {
+ home_dir, err := os.UserHomeDir()
+ if err != nil {
+ return
+ }
+ v = home_dir + (v)[1:]
+ }
+ v, _ = filepath.Abs(v)
+ insert.Drive[k] = v
+ }
+ }
}
func i_insert_default_users(insert *HostNode) {
@@ -124,6 +137,9 @@ func i_insert_default_users(insert *HostNode) {
func i_insert_host(data *HardData, insert *HostNode) {
i_insert_abs_files(insert)
i_insert_default_users(insert)
+ if len(insert.Drive) == 0 {
+ insert.Drive = nil
+ }
filename := i_insert_format_filename(insert.Name,
data.data_dir + insert.parent.path())
insert.filename = filename
@@ -207,7 +223,7 @@ func i_insert_check_ok(data *HardData, in *HostNode) {
v = home_dir + v[1:]
}
if stat, err := os.Stat(v);
- err != nil {
+ err != nil {
data.insert_err = append(data.insert_err, errors.New(v +
": file does not exist"))
} else if stat.IsDir() == true {
@@ -216,6 +232,23 @@ func i_insert_check_ok(data *HardData, in *HostNode) {
}
}
}
+ for _, v := range in.Drive {
+ if v[0] == '~' {
+ home_dir, err := os.UserHomeDir()
+ if err != nil {
+ return
+ }
+ v = home_dir + v[1:]
+ }
+ if stat, err := os.Stat(v);
+ err != nil {
+ data.insert_err = append(data.insert_err, errors.New(v +
+ ": path does not exist"))
+ } else if stat.IsDir() == false {
+ data.insert_err = append(data.insert_err, errors.New(v +
+ ": path is not a directory"))
+ }
+ }
}
func i_draw_tick_box(ui HardUI, line int, dim Quad, label string, content bool,