Skip to content

Commit

Permalink
Removed unneeded comment and changed logic to unindent some lines
Browse files Browse the repository at this point in the history
  • Loading branch information
klingbolt committed Aug 22, 2024
1 parent c1c9f42 commit bbc1977
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions FileHandler.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,30 @@ static func create_directory_if_missing(path: String):

static func find_file_duplicate(directory_path: String, target_name: String, target_content: PoolByteArray, relative_path: String):
var dir = Directory.new()
if dir.open(directory_path) == OK:
dir.list_dir_begin(true)
var file_name = dir.get_next()
while file_name != "":
var full_path = directory_path.plus_file(file_name)
var current_relative_path = relative_path.plus_file(file_name)
if dir.current_is_dir():
var found_path = find_file_duplicate(full_path, target_name, target_content, current_relative_path)
if found_path != "":
dir.list_dir_end()
return found_path
if file_name == target_name:
var file = File.new()
file.open(full_path, File.READ)
var file_content = file.get_buffer(file.get_len())
file.close()
if file_content == target_content:
dir.list_dir_end()
return current_relative_path
file_name = dir.get_next()
return ""
if dir.open(directory_path) != OK:
return null
dir.list_dir_begin(true)
var file_name = dir.get_next()
while file_name != "":
var full_path = directory_path.plus_file(file_name)
var current_relative_path = relative_path.plus_file(file_name)
if dir.current_is_dir():
var found_path = find_file_duplicate(full_path, target_name, target_content, current_relative_path)
if found_path != "":
dir.list_dir_end()
return found_path
if file_name == target_name:
var file = File.new()
file.open(full_path, File.READ)
var file_content = file.get_buffer(file.get_len())
file.close()
if file_content == target_content:
dir.list_dir_end()
return current_relative_path
file_name = dir.get_next()
return null

static func find_image_duplicates(file_path: String, destintation_dir: String) -> String:
# These are all supported file types in Godot that are not supported
# by other marker programs. "jpg", "jpeg", "bmp", "tga"
static func find_image_duplicates(file_path: String, destintation_dir: String):
var file_name: String = file_path.get_file()
var file_extension: String = file_name.get_extension().to_lower()
if not file_extension == "png":
Expand Down

0 comments on commit bbc1977

Please sign in to comment.