Skip to content

Commit

Permalink
fix editFileVisibility proc's code
Browse files Browse the repository at this point in the history
  • Loading branch information
neroist committed Mar 13, 2024
1 parent d4d2e02 commit 2d39cf7
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/commands/setup.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,27 @@ import puppy
import ../common

proc editFileVisibility*(file: string; hidden: bool) =
## Edit file visibility of the file `file`. Only edits for Windows and
## MacOS, as you can hide a file in linux by simply adding a period before
## the file name (and show a file by removing the period).
## Edit file visibility of the file `file`.
##
## Only operates on Windows and MacOS, is simply a noop on Linux.

var
winoption = "+h"
macoption = "hidden"
when defined(windows):
var winoption = "+h"

if defined(windows) and (not hidden):
winoption = "-h"
elif (defined(macos) or defined(macosx)) and (not hidden):
macoption = "nohidden"
if not hidden:
winoption = "-h"

when defined(windows):
discard execShellCmd(fmt"attrib {winoption} {file}") # add "hidden" attribute to file
elif defined(macos) or defined(macosx):
discard execShellCmd(fmt"chflags {macoption} {file}") # set "hidden" flag on file
var macoption = "hidden"

if not hidden:
winoption = "nohidden"

discard execShellCmd(fmt"chflags {macoption} {file}")

proc applyPermissions*(file: string) =
inclFilePermissions(file, {fpUserWrite, fpUserRead, fpOthersWrite, fpOthersRead})

proc setup* =
## Setup Nova
Expand All @@ -40,7 +44,7 @@ proc setup* =
code = response.code

if code == 200:
# we "un-hide" the the .KEY file incase it exists already because
# we "un-hide" the the .KEY file incase it exists already
# we cant write to a hidden file, apparently
if fileExists keyFile:
editFileVisibility(keyFile, hidden=false)
Expand Down

0 comments on commit 2d39cf7

Please sign in to comment.