Fix some deprecated functions in windows code

This commit is contained in:
2023-10-06 01:34:25 -05:00
parent 9f28a6900d
commit 84822200ed
2 changed files with 9 additions and 5 deletions

View File

@@ -6,7 +6,7 @@ package duplicacy
import (
"encoding/json"
"io/ioutil"
"os"
"syscall"
"unsafe"
)
@@ -86,7 +86,7 @@ func keyringGet(key string) (value string) {
return ""
}
description, err := ioutil.ReadFile(keyringFile)
description, err := os.ReadFile(keyringFile)
if err != nil {
LOG_DEBUG("KEYRING_READ", "Keyring file not read: %v", err)
return ""
@@ -125,7 +125,7 @@ func keyringSet(key string, value string) bool {
keyring := make(map[string][]byte)
description, err := ioutil.ReadFile(keyringFile)
description, err := os.ReadFile(keyringFile)
if err == nil {
err = json.Unmarshal(description, &keyring)
if err != nil {
@@ -160,7 +160,7 @@ func keyringSet(key string, value string) bool {
return false
}
err = ioutil.WriteFile(keyringFile, description, 0600)
err = os.WriteFile(keyringFile, description, 0600)
if err != nil {
LOG_DEBUG("KEYRING_WRITE", "Failed to save the keyring storage to file %s: %v", keyringFile, err)
return false

View File

@@ -56,7 +56,11 @@ const (
// Readlink returns the destination of the named symbolic link.
func Readlink(path string) (isRegular bool, s string, err error) {
fd, err := syscall.CreateFile(syscall.StringToUTF16Ptr(path), FILE_READ_ATTRIBUTES,
pPath, err := syscall.UTF16PtrFromString(path)
if err != nil {
return false, "", err
}
fd, err := syscall.CreateFile(pPath, FILE_READ_ATTRIBUTES,
syscall.FILE_SHARE_READ, nil, syscall.OPEN_EXISTING,
syscall.FILE_FLAG_OPEN_REPARSE_POINT|syscall.FILE_FLAG_BACKUP_SEMANTICS, 0)
if err != nil {