Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | michaelpbl |
Here’s a simple script to demonstrate the problem
extends Node2D
var basePath = "D://Documents/Dropbox/MichaelsDocuments/GodotProjects/fileCopy"
var localPath = "saves"
func _ready():
autoSave()
func autoSave():
var directory = Directory.new()
var dirErr = directory.open(basePath)
if dirErr != OK:
printerr("Couldn't open directory " + basePath)
return
dirErr = directory.change_dir(localPath)
if dirErr != OK:
printerr("Couldn't change directory to" + basePath + "/" + localPath)
return
print("Current directory is " + directory.get_current_dir())
var fName = "savefile.txt"
if directory.file_exists(fName):
print(fName + " does exist")
# old backup automatically overwritten if it exists
var backupName = "savefile-backup.txt"
var reName = "savefile-renamed.txt"
print("Trying to copy " + fName + " to " + backupName)
directory.copy(fName, backupName)
print("Trying to rename " + fName + " to " + reName)
directory.rename(fName,reName)
And here’s the console output
Current directory is D:/Documents/Dropbox/MichaelsDocuments/GodotProjects/fileCopy/saves
savefile.txt does exist
Trying to copy savefile.txt to savefile-backup.txt
ERROR: copy: Failed to open savefile.txt
At: core/os/dir_access.cpp:288
Trying to rename savefile.txt to savefile-renamed.txt
The copy
fails but the rename
command works. To me that says there is nothing wrong with my setup but there is a problem with the copy
command, at least insofar as working with Access File system
. After considerable trial and effort, I have adopted Access File system
as being best for my purposes and am not willing to change it.
I’m using window 10 and Godot v3.2.1.stable.official