Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0e01988
Place shared constants in shared file
marchc1 Jun 28, 2025
c44e788
Couple of formatting things that annoyed me
marchc1 Jun 28, 2025
986e934
Temporary hard-refresh-advdupe2 button
marchc1 Jun 28, 2025
acd4f1c
Initial file browser V2 work
marchc1 Jun 28, 2025
e144c74
Typo
marchc1 Jun 28, 2025
7ab20de
Move GetFilename to its own file
marchc1 Jun 28, 2025
a3b1453
Move parameters to convars
marchc1 Jun 28, 2025
23c3d41
Switch CurTime to RealTime
marchc1 Jun 28, 2025
c0c18ce
Various other WIP changes
marchc1 Jun 28, 2025
e17bacf
Actually include sh_file.lua
marchc1 Jun 28, 2025
3669c47
Further strip out unused V1 methods
marchc1 Jun 28, 2025
f93bd42
Even more V1 method stripping
marchc1 Jun 28, 2025
d41d5e4
Turn the rest of these into convars
marchc1 Jun 28, 2025
9016aa3
Slight rethinking
marchc1 Jun 28, 2025
a9c91c2
Flesh out user prompts
marchc1 Jun 29, 2025
e623368
Add file saving back
marchc1 Jun 29, 2025
b68a9fe
WIP folder logic
marchc1 Jun 29, 2025
dbdd284
Fix a couple bugs, implement makefolder
marchc1 Jun 29, 2025
2975225
Simplify more of what's left of V1
marchc1 Jun 29, 2025
fd3e35e
Settings menu and further UI work
marchc1 Jun 29, 2025
40e2773
Add some IRootFolder methods
marchc1 Jun 29, 2025
55cc496
Make my linter happier with me
marchc1 Jun 29, 2025
ad6050b
Add renaming, fix duplicate files
marchc1 Jul 1, 2025
1af89a6
AdvDupe1 stubs
marchc1 Jul 1, 2025
8fea35f
Fix userprompt panels not being cleaned up
marchc1 Jul 1, 2025
1527c00
Clear userprompts on refresh files
marchc1 Jul 1, 2025
02da163
Fix being unable to load dupes this way
marchc1 Jul 1, 2025
5762031
Menu changes?
marchc1 Jul 1, 2025
f90e445
Download prompts
marchc1 Jul 2, 2025
6c02dbd
Remove attribution
marchc1 Jul 3, 2025
97a5e03
Implement StartDelete, AdvDupe2Folder:UserDelete
marchc1 Jul 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 32 additions & 25 deletions lua/advdupe2/cl_file.lua
Comment thread
marchc1 marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local invalidCharacters = { "\"", ":"}
function AdvDupe2.SanitizeFilename(filename)
for i=1, #invalidCharacters do
for i = 1, #invalidCharacters do
filename = string.gsub(filename, invalidCharacters[i], "_")
end
filename = string.gsub(filename, "%s+", " ")
Expand All @@ -16,15 +16,15 @@ function AdvDupe2.ReceiveFile(data, autoSave)
end
local path
if autoSave then
if(LocalPlayer():GetInfo("advdupe2_auto_save_overwrite")~="0")then
if LocalPlayer():GetInfo("advdupe2_auto_save_overwrite") ~= "0" then
path = AdvDupe2.GetFilename(AdvDupe2.AutoSavePath, true)
else
path = AdvDupe2.GetFilename(AdvDupe2.AutoSavePath)
end
else
path = AdvDupe2.GetFilename(AdvDupe2.SavePath)
end

local OriginalPath = AdvDupe2.SavePath .. ".txt"
path = AdvDupe2.SanitizeFilename(path)
local dupefile = file.Open(path, "wb", "DATA")
if not dupefile then
Expand All @@ -35,15 +35,15 @@ function AdvDupe2.ReceiveFile(data, autoSave)
dupefile:Close()

local errored = false
if(LocalPlayer():GetInfo("advdupe2_debug_openfile")=="1")then
if(not file.Exists(path, "DATA"))then AdvDupe2.Notify("File does not exist", NOTIFY_ERROR) return end
if LocalPlayer():GetInfo("advdupe2_debug_openfile") == "1" then
if not file.Exists(path, "DATA") then AdvDupe2.Notify("File does not exist", NOTIFY_ERROR) return end

local readFile = file.Open(path, "rb", "DATA")
if not readFile then AdvDupe2.Notify("File could not be read", NOTIFY_ERROR) return end
local readData = readFile:Read(readFile:Size())
readFile:Close()
local success,dupe,info,moreinfo = AdvDupe2.Decode(readData)
if(success)then
local success, dupe = AdvDupe2.Decode(readData)
if success then
AdvDupe2.Notify("DEBUG CHECK: File successfully opens. No EOF errors.")
else
AdvDupe2.Notify("DEBUG CHECK: " .. dupe, NOTIFY_ERROR)
Expand All @@ -52,25 +52,29 @@ function AdvDupe2.ReceiveFile(data, autoSave)
end

local filename = string.StripExtension(string.GetFileFromFilename( path ))

local Browser = AdvDupe2.FileBrowser.Browser

if autoSave then
if(IsValid(AdvDupe2.FileBrowser.AutoSaveNode))then
if IsValid(AdvDupe2.FileBrowser.AutoSaveNode) then
local add = true
for i=1, #AdvDupe2.FileBrowser.AutoSaveNode.Files do
if(filename==AdvDupe2.FileBrowser.AutoSaveNode.Files[i].Label:GetText())then
add=false
for i = 1, #AdvDupe2.FileBrowser.AutoSaveNode.Files do
if filename == AdvDupe2.FileBrowser.AutoSaveNode.Files[i].Label:GetText() then
add = false
break
end
end
if(add)then
AdvDupe2.FileBrowser.AutoSaveNode:AddFile(filename)
AdvDupe2.FileBrowser.Browser.pnlCanvas:Sort(AdvDupe2.FileBrowser.AutoSaveNode)
if add then
error "Not implemented yet"
Comment thread
marchc1 marked this conversation as resolved.
-- AutoSaveNode:AddFile(filename)
-- Browser.pnlCanvas:Sort(AdvDupe2.FileBrowser.AutoSaveNode)
end
end
else
AdvDupe2.FileBrowser.Browser.pnlCanvas.ActionNode:AddFile(filename)
AdvDupe2.FileBrowser.Browser.pnlCanvas:Sort(AdvDupe2.FileBrowser.Browser.pnlCanvas.ActionNode)
Browser:IncomingFile(OriginalPath, path)
end
if(!errored)then

if not errored then
AdvDupe2.Notify("File successfully saved!",NOTIFY_GENERIC, 5)
end
end
Expand All @@ -94,17 +98,20 @@ function AdvDupe2.SendFile(name, data)
net.SendToServer()
end

local ADVDUPE2_AREA_ADVDUPE2 = AdvDupe2.AREA_ADVDUPE2
local ADVDUPE2_AREA_PUBLIC = AdvDupe2.AREA_PUBLIC

function AdvDupe2.UploadFile(ReadPath, ReadArea)
if AdvDupe2.Uploading then AdvDupe2.Notify("Already opening file, please wait.", NOTIFY_ERROR) return end
if(ReadArea==0)then
ReadPath = AdvDupe2.DataFolder.."/"..ReadPath..".txt"
elseif(ReadArea==1)then
ReadPath = AdvDupe2.DataFolder.."/-Public-/"..ReadPath..".txt"
if ReadArea == ADVDUPE2_AREA_ADVDUPE2 then
ReadPath = AdvDupe2.DataFolder .. "/" .. ReadPath .. ".txt"
elseif ReadArea == ADVDUPE2_AREA_PUBLIC then
ReadPath = AdvDupe2.DataFolder .. "/-Public-/" .. ReadPath .. ".txt"
else
ReadPath = "adv_duplicator/"..ReadPath..".txt"
ReadPath = "adv_duplicator/" .. ReadPath .. ".txt"
end

if(not file.Exists(ReadPath, "DATA"))then AdvDupe2.Notify("File does not exist", NOTIFY_ERROR) return end
if not file.Exists(ReadPath, "DATA") then AdvDupe2.Notify("File does not exist", NOTIFY_ERROR) return end

local read = file.Read(ReadPath)
if not read then AdvDupe2.Notify("File could not be read", NOTIFY_ERROR) return end
Expand All @@ -113,11 +120,11 @@ function AdvDupe2.UploadFile(ReadPath, ReadArea)
name = string.sub(name, 1, #name-4)

local success, dupe, info, moreinfo = AdvDupe2.Decode(read)
if(success)then
if success then
AdvDupe2.SendFile(name, read)

AdvDupe2.LoadGhosts(dupe, info, moreinfo, name)
else
AdvDupe2.Notify("File could not be decoded. ("..dupe..") Upload Canceled.", NOTIFY_ERROR)
AdvDupe2.Notify("File could not be decoded. (" .. dupe .. ") Upload Canceled.", NOTIFY_ERROR)
end
end
Loading
Loading