mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2025-10-30 17:46:41 +08:00
15 lines
341 B
Go
15 lines
341 B
Go
package common
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
)
|
|
|
|
func SafeOsOpenFile(path string, flag int, perm os.FileMode) (*os.File, error) {
|
|
if err := safePath(path); err != nil {
|
|
Log.Debug("common::files safeOsOpenFile err[%s] path[%s]", err.Error(), path)
|
|
return nil, ErrFilesystemError
|
|
}
|
|
return os.OpenFile(path, flag|syscall.O_NOFOLLOW, perm)
|
|
}
|