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) {
|
2022-07-06 23:01:54 +02:00
|
|
|
tmpName := filepath.Join(storagePath, ".caseTest.tmp")
|
2020-12-26 18:06:54 +01:00
|
|
|
|
2022-10-31 15:01:48 +01:00
|
|
|
if err = os.WriteFile(tmpName, []byte("{}"), ModeFile); err != nil {
|
2020-12-26 18:06:54 +01:00
|
|
|
return false, fmt.Errorf("%s not writable", filepath.Base(storagePath))
|
|
|
|
}
|
|
|
|
|
|
|
|
defer os.Remove(tmpName)
|
|
|
|
|
2022-07-06 23:01:54 +02:00
|
|
|
result = FileExists(filepath.Join(storagePath, ".CASETEST.TMP"))
|
2020-12-26 18:06:54 +01:00
|
|
|
|
|
|
|
return result, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// IgnoreCase enables the case-insensitive mode.
|
|
|
|
func IgnoreCase() {
|
|
|
|
ignoreCase = true
|
2022-04-15 09:42:07 +02:00
|
|
|
FileTypes = Extensions.Types(true)
|
2020-12-26 18:06:54 +01:00
|
|
|
}
|