mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-28 04:46:41 -04:00
Replace use of ASCII control characters with unicode characters allowed in Windows filenames (fixes shearing with a Windows server)
This commit is contained in:
@@ -4,7 +4,7 @@ function cliMUTNEntryCompleter {
|
||||
$mutnPath = (Resolve-Path '~\AppData\Local\libmutton\entries').Path
|
||||
try {
|
||||
$trimmedPaths = If (Test-Path $mutnPath) {
|
||||
(Get-ChildItem -Path $mutnPath -Recurse -File).FullName.Substring($mutnPath.Length) -replace '\\', '/' -replace ' ', [char]0x23bd
|
||||
(Get-ChildItem -Path $mutnPath -Recurse -File).FullName.Substring($mutnPath.Length) -replace '\\', '/' -replace ' ', [char]0x259d
|
||||
}
|
||||
} catch {
|
||||
$trimmedPaths = $null # if any errors occur (especially, "You cannot call a method on a null-valued expression", set $trimmedPaths to $null
|
||||
@@ -50,6 +50,6 @@ function mutn {
|
||||
[string]$option
|
||||
)
|
||||
|
||||
#Invoke-Expression -Command ('/usr/local/bin/mutn ' + ($entry -replace ' ', '` ' -replace [char]0x1a, '` '), $argument, $option).Trim() # UNIX testing
|
||||
Invoke-Expression -Command ('mutn.exe ' + ($entry -replace ' ', '` ' -replace [char]0x23bd, '` '), $argument, $option).Trim()
|
||||
#Invoke-Expression -Command ('/usr/local/bin/mutn ' + ($entry -replace ' ', '` ' -replace [char]0x259d, '` '), $argument, $option).Trim() # UNIX testing
|
||||
Invoke-Expression -Command ('mutn.exe ' + ($entry -replace ' ', '` ' -replace [char]0x259d, '` '), $argument, $option).Trim()
|
||||
}
|
||||
|
||||
+8
-13
@@ -11,11 +11,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Field separator key:
|
||||
// \x1d = path separator
|
||||
// \x1e = space/list separator
|
||||
// \x1f = misc. field separator (if \x1e is already used)
|
||||
|
||||
func main() {
|
||||
args := os.Args
|
||||
if len(args) < 2 {
|
||||
@@ -43,25 +38,25 @@ func main() {
|
||||
case "rename":
|
||||
// move an entry to a new location before using fallthrough to add its previous iteration to the deletions directory
|
||||
// stdin[0] is evaluated after fallthrough
|
||||
// stdin[1] is expected to be the OLD incomplete target location with "\x1d" representing path separators - always pass in UNIX format
|
||||
// stdin[2] is expected to be the NEW incomplete target location with "\x1d" representing path separators - always pass in UNIX format
|
||||
sync.RenameLocal(strings.ReplaceAll(stdin[1], "\x1d", "/"), strings.ReplaceAll(stdin[2], "\x1d", "/"))
|
||||
// stdin[1] is expected to be the OLD incomplete target location with FSPath representing path separators - always pass in UNIX format
|
||||
// stdin[2] is expected to be the NEW incomplete target location with FSPath representing path separators - always pass in UNIX format
|
||||
sync.RenameLocal(strings.ReplaceAll(stdin[1], sync.FSPath, "/"), strings.ReplaceAll(stdin[2], sync.FSPath, "/"))
|
||||
fallthrough // fallthrough to add the old entry to the deletions directory
|
||||
case "shear":
|
||||
// shear an entry from the server and add it to the deletions directory
|
||||
// stdin[0] is expected to be the device ID
|
||||
// stdin[1] is expected to be the incomplete target location with "\x1d" representing path separators - always pass in UNIX format
|
||||
sync.ShearLocal(strings.ReplaceAll(stdin[1], "\x1d", "/"), stdin[0])
|
||||
// stdin[1] is expected to be the incomplete target location with FSPath representing path separators - always pass in UNIX format
|
||||
sync.ShearLocal(strings.ReplaceAll(stdin[1], sync.FSPath, "/"), stdin[0])
|
||||
case "addfolder":
|
||||
// add a new folder to the server
|
||||
// stdin[0] is expected to be the incomplete target location with "\x1d" representing path separators - always pass in UNIX format
|
||||
sync.AddFolderLocal(strings.ReplaceAll(stdin[0], "\x1d", "/"))
|
||||
// stdin[0] is expected to be the incomplete target location with FSPath representing path separators - always pass in UNIX format
|
||||
sync.AddFolderLocal(strings.ReplaceAll(stdin[0], sync.FSPath, "/"))
|
||||
case "register":
|
||||
// register a new device ID
|
||||
// stdin[0] is expected to be the device ID
|
||||
_, _ = os.Create(backend.ConfigDir + backend.PathSeparator + "devices" + backend.PathSeparator + stdin[0]) // error ignored; failure unlikely to occur if init was successful; "register" is not a user-facing argument and thus the error would not be visible
|
||||
// print EntryRoot and bool indicating OS type to stdout for client to store in config
|
||||
fmt.Print(backend.EntryRoot + "\x1e" + strconv.FormatBool(backend.IsWindows))
|
||||
fmt.Print(backend.EntryRoot + sync.FSSpace + strconv.FormatBool(backend.IsWindows))
|
||||
case "init":
|
||||
// create the necessary directories for libmuttonserver to function
|
||||
backend.DirInit(false)
|
||||
|
||||
Reference in New Issue
Block a user