This happens when folders contain a custom icon. Co-authored-by: Alexandre Alves <alexandrealvesdb.contact@gmail.com>
This commit is contained in:
co-authored by
Alexandre Alves
parent
5e384c9185
commit
a29605750d
@@ -13,6 +13,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -192,3 +193,25 @@ func TestGetFinalPath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoveWindowsDirIcon(t *testing.T) {
|
||||
//Try to delete a folder with a custom icon with os.Remove (simulated by the readonly file attribute)
|
||||
|
||||
fs, dir := setup(t)
|
||||
relativePath := "folder_with_icon"
|
||||
path := filepath.Join(dir, relativePath)
|
||||
|
||||
if err := os.Mkdir(path, os.ModeDir); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ptr, err := syscall.UTF16PtrFromString(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := syscall.SetFileAttributes(ptr, uint32(syscall.FILE_ATTRIBUTE_DIRECTORY+syscall.FILE_ATTRIBUTE_READONLY)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := fs.Remove(relativePath); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user