-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(windows): Set .qri-ref as hidden in Windows
- Loading branch information
Showing
3 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// +build !windows | ||
|
||
package fsi | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
"strings" | ||
) | ||
|
||
// setFileHidden ensures the filename begins with a dot. Other OSes may do more | ||
func setFileHidden(path string) error { | ||
basename := filepath.Base(path) | ||
if !strings.HasPrefix(basename, ".") { | ||
return fmt.Errorf("hidden files must begin with \".\"") | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package fsi | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
"strings" | ||
"syscall" | ||
) | ||
|
||
// setFileHidden sets the hidden attribute on the given file. Windows specific functionality | ||
func setFileHidden(path string) error { | ||
basename := filepath.Base(path) | ||
if !strings.HasPrefix(basename, ".") { | ||
return fmt.Errorf("hidden files must begin with \".\"") | ||
} | ||
filenamePtr, err := syscall.UTF16PtrFromString(path) | ||
if err != nil { | ||
return err | ||
} | ||
return syscall.SetFileAttributes(filenamePtr, syscall.FILE_ATTRIBUTE_HIDDEN) | ||
} |