2020-12-26 18:06:54 +01:00
|
|
|
package fs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
// CaseInsensitive tests if a storage path is case-insensitive.
|
|
|
|
func CaseInsensitive(storagePath string) (result bool, err error) {
|
|
|
|
tmpName := filepath.Join(storagePath, "caseTest.tmp")
|
|
|
|
|
2021-10-06 07:10:50 +02:00
|
|
|
if err := os.WriteFile(tmpName, []byte("{}"), 0666); err != nil {
|
2020-12-26 18:06:54 +01:00
|
|
|
return false, fmt.Errorf("%s not writable", filepath.Base(storagePath))
|
|
|
|
}
|
|
|
|
|
|
|
|
defer os.Remove(tmpName)
|
|
|
|
|
|
|
|
result = FileExists(filepath.Join(storagePath, "CASETEST.TMP"))
|
|
|
|
|
|
|
|
return result, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// IgnoreCase enables the case-insensitive mode.
|
|
|
|
func IgnoreCase() {
|
|
|
|
ignoreCase = true
|
2022-04-12 13:28:28 +02:00
|
|
|
Formats = Extensions.Formats(true)
|
2020-12-26 18:06:54 +01:00
|
|
|
}
|