feat: 完成自动创建文件部分
This commit is contained in:
@@ -1,24 +1,40 @@
|
||||
extends Node
|
||||
|
||||
func _ready() -> void:
|
||||
print(OS.get_user_data_dir())
|
||||
|
||||
func create_file(file_path: String) -> void:
|
||||
var base_dir = file_path.get_base_dir()
|
||||
if !DirAccess.dir_exists_absolute(base_dir):
|
||||
DirAccess.make_dir_recursive_absolute(base_dir)
|
||||
FileAccess.open(file_path, FileAccess.WRITE)
|
||||
|
||||
func download_file(server_path: String, local_path: String) -> void:
|
||||
var http = HTTPRequest.new()
|
||||
http.download_file = local_path
|
||||
http.request(server_path)
|
||||
var http = HTTPRequest.new()
|
||||
add_child(http)
|
||||
var file_path = "user://downloads_test/" + local_path
|
||||
if !FileAccess.file_exists(file_path):
|
||||
create_file(file_path)
|
||||
http.set_download_file(file_path)
|
||||
http.request(server_path)
|
||||
|
||||
func download_from_origin() -> int:
|
||||
var origin = GameManager.data_origin
|
||||
var http = HTTPRequest.new()
|
||||
var origin = GameManager.data_origin
|
||||
var http = HTTPRequest.new()
|
||||
add_child(http)
|
||||
|
||||
if origin.substr(0, 4) != "http":
|
||||
return 1
|
||||
|
||||
if http.request(origin) != OK:
|
||||
return 2
|
||||
if origin.substr(0, 4) != "http":
|
||||
return 1
|
||||
|
||||
if http.request(origin) != OK:
|
||||
return 2
|
||||
|
||||
if origin[-1] != "/":
|
||||
origin = origin + "/"
|
||||
if origin[-1] != "/":
|
||||
origin = origin + "/"
|
||||
|
||||
return 0
|
||||
download_file(origin + "card/id/Oxygen", "test_Oxygen.json")
|
||||
|
||||
return 0
|
||||
|
||||
func load_resource():
|
||||
pass
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user