From 7cd1069f67ac63b0c4c02c2287e176663beffad7 Mon Sep 17 00:00:00 2001 From: Azarak Date: Wed, 30 Sep 2020 01:22:38 +0200 Subject: [PATCH] Revert "[MIRROR] Adds some file helpers for working with byond file references in external systems (#1059)" (#1064) This reverts commit aee60f400844aa5f42c3d1c14245c8208aa42ad5. --- code/__HELPERS/files.dm | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/code/__HELPERS/files.dm b/code/__HELPERS/files.dm index 54aeda2d115..b4c8fecf54a 100644 --- a/code/__HELPERS/files.dm +++ b/code/__HELPERS/files.dm @@ -81,38 +81,10 @@ /// Save file as an external file then md5 it. /// Used because md5ing files stored in the rsc sometimes gives incorrect md5 results. /proc/md5asfile(file) - var/filename = file2filepath(file) - var/istmp = FALSE - if (!filename || length(filename) < 1) - // its importaint this code can handle md5filepath sleeping instead of hard blocking, if it's converted to use rust_g. - filename = generate_tmp_filepath("md5asfile") - fcopy(file, filename) - istmp = TRUE - . = md5filepath(filename) - if (istmp) - fdel(filename) - -/// Generate a unique filepath inside the tmp folder. -/// namespace - a optional string to prepend to the filename, useful for knowing what isn't cleaning up their things in the tmp folder -/proc/generate_tmp_filepath(namespace = "tmpfile") var/static/notch = 0 - . = "tmp/[namespace].[world.realtime].[world.timeofday].[world.time].[world.tick_usage].[notch]" + // its importaint this code can handle md5filepath sleeping instead of hard blocking, if it's converted to use rust_g. + var/filename = "tmp/md5asfile.[world.realtime].[world.timeofday].[world.time].[world.tick_usage].[notch]" notch = WRAP(notch+1, 0, 2^15) - -/// Returns the filepath a given file reference can be found at. -/// returns null if the file exists only in the rsc (modified icons), in those cases just fcopy() the file to the tmp folder and clean it up when you are done -/// file_or_icon - A file, rsc cache reference, or /icon. -/proc/file2filepath(file_or_icon) - if (istype(file_or_icon, /icon)) - var/icon/I = file_or_icon - file_or_icon = I.icon //undocumented var, stores the actual file reference the icon is at, almost always a rsc cache entry - if (!isfile(file_or_icon)) - CRASH("file2filepath: unknown input: [file_or_icon] (\ref[file_or_icon]) - [json_encode(file_or_icon)]") - . = "[locate("\ref[file_or_icon]")]" - if (length(.) < 1) - return null - - - - - + fcopy(file, filename) + . = md5filepath(filename) + fdel(filename)