Removing and writing again if the newpath alredy exists while moving, copying and doing symbolic links
This commit is contained in:
@@ -220,6 +220,9 @@ func SafeRename(L *lua.LState) int {
|
|||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, err := os.Stat(newname); err == nil {
|
||||||
|
os.RemoveAll(newname)
|
||||||
|
}
|
||||||
if err := os.Rename(oldname, newname); err != nil {
|
if err := os.Rename(oldname, newname); err != nil {
|
||||||
L.Push(lua.LFalse)
|
L.Push(lua.LFalse)
|
||||||
L.Push(lua.LString("[packets] rename failed\n" + err.Error()))
|
L.Push(lua.LString("[packets] rename failed\n" + err.Error()))
|
||||||
@@ -262,6 +265,10 @@ func SafeCopy(L *lua.LState) int {
|
|||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, err := os.Stat(newname); err == nil {
|
||||||
|
os.RemoveAll(newname)
|
||||||
|
}
|
||||||
|
|
||||||
dst, err := os.Create(newname)
|
dst, err := os.Create(newname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
L.Push(lua.LFalse)
|
L.Push(lua.LFalse)
|
||||||
@@ -298,6 +305,10 @@ func SymbolicLua(L *lua.LState) int {
|
|||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, err := os.Stat(destination); err == nil {
|
||||||
|
os.RemoveAll(destination)
|
||||||
|
}
|
||||||
|
|
||||||
if err := os.Symlink(fileName, destination); err != nil {
|
if err := os.Symlink(fileName, destination); err != nil {
|
||||||
L.Push(lua.LFalse)
|
L.Push(lua.LFalse)
|
||||||
L.Push(lua.LString("[packets] symlink failed\n" + err.Error()))
|
L.Push(lua.LString("[packets] symlink failed\n" + err.Error()))
|
||||||
|
|||||||
Reference in New Issue
Block a user