Add --force-binary-read flag
This commit is contained in:
@@ -44,6 +44,12 @@ lune run detector.lua --directory /path/to/your/directory/with/models
|
|||||||
lune run detector.lua --output /path/to/your/output/file.txt
|
lune run detector.lua --output /path/to/your/output/file.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Process non-extensioned files (i.e no filetype extension / differing extension from .rbxm)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
lune run detector.lua --force-binary-read /path/to/your/model.variantfile
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|||||||
+16
-5
@@ -14,6 +14,8 @@ if #args < 1 then
|
|||||||
stdio.write(" lune run detector --o output.txt file1.rbxm file2.rbxm\n")
|
stdio.write(" lune run detector --o output.txt file1.rbxm file2.rbxm\n")
|
||||||
stdio.write(" lune run detector --output output.txt file1.rbxm file2.rbxm\n")
|
stdio.write(" lune run detector --output output.txt file1.rbxm file2.rbxm\n")
|
||||||
stdio.write(" lune run detector --directory path/to/folder --o output.txt\n")
|
stdio.write(" lune run detector --directory path/to/folder --o output.txt\n")
|
||||||
|
stdio.write(" lune run detector --force-binary-read file1 file2.bin file3.robloxmodelfile\n")
|
||||||
|
stdio.write(" lune run detector --directory path/to/folder --force-binary-read\n")
|
||||||
stdio.write(stdio.color("reset"))
|
stdio.write(stdio.color("reset"))
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
end
|
end
|
||||||
@@ -57,6 +59,8 @@ end
|
|||||||
local outputFile = nil
|
local outputFile = nil
|
||||||
local directoryMode = false
|
local directoryMode = false
|
||||||
local directoryPath = nil
|
local directoryPath = nil
|
||||||
|
-- i mainly added this arg because the modelscrape files dont have extensions and i dont feel like changing all of them ~ivy
|
||||||
|
local forceBinaryRead = false
|
||||||
local filesToProcess = {}
|
local filesToProcess = {}
|
||||||
|
|
||||||
local i = 1
|
local i = 1
|
||||||
@@ -82,6 +86,9 @@ while i <= #args do
|
|||||||
directoryMode = true
|
directoryMode = true
|
||||||
directoryPath = args[i + 1]
|
directoryPath = args[i + 1]
|
||||||
i = i + 2
|
i = i + 2
|
||||||
|
elseif arg == "--force-binary-read" then
|
||||||
|
forceBinaryRead = true
|
||||||
|
i = i + 1
|
||||||
else
|
else
|
||||||
-- regular file argument
|
-- regular file argument
|
||||||
if not directoryMode then
|
if not directoryMode then
|
||||||
@@ -110,12 +117,14 @@ if directoryMode then
|
|||||||
process.exit(1)
|
process.exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- read directory and collect .rbxm and .rbxmx files
|
-- read directory and collect files
|
||||||
local function readDirLoop(dirPath)
|
local function readDirLoop(dirPath)
|
||||||
for _, file in pairs(fs.readDir(dirPath)) do
|
for _, file in pairs(fs.readDir(dirPath)) do
|
||||||
local fullPath = dirPath .. "/" .. file
|
local fullPath = dirPath .. "/" .. file
|
||||||
if fs.isFile(fullPath) and isValidModelFile(file) then
|
if fs.isFile(fullPath) then
|
||||||
table.insert(filesToProcess, fullPath)
|
if forceBinaryRead or isValidModelFile(file) then
|
||||||
|
table.insert(filesToProcess, fullPath)
|
||||||
|
end
|
||||||
elseif fs.isDir(fullPath) then
|
elseif fs.isDir(fullPath) then
|
||||||
readDirLoop(fullPath)
|
readDirLoop(fullPath)
|
||||||
end
|
end
|
||||||
@@ -126,11 +135,12 @@ if directoryMode then
|
|||||||
|
|
||||||
if #filesToProcess == 0 then
|
if #filesToProcess == 0 then
|
||||||
stdio.write(stdio.color("yellow"))
|
stdio.write(stdio.color("yellow"))
|
||||||
stdio.write(`Warning: No .rbxm or .rbxmx files found in directory {directoryPath}.\n`)
|
stdio.write(`Warning: No files found in directory {directoryPath}.\n`)
|
||||||
stdio.write(stdio.color("reset"))
|
stdio.write(stdio.color("reset"))
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if #filesToProcess == 0 then
|
if #filesToProcess == 0 then
|
||||||
stdio.write(stdio.color("red"))
|
stdio.write(stdio.color("red"))
|
||||||
stdio.write("Error: No files to process.\n")
|
stdio.write("Error: No files to process.\n")
|
||||||
@@ -142,13 +152,14 @@ local totalFiles = #filesToProcess
|
|||||||
local filesWithWorkspace = {}
|
local filesWithWorkspace = {}
|
||||||
local processedFiles = 0
|
local processedFiles = 0
|
||||||
|
|
||||||
|
|
||||||
stdio.write(`Processing {totalFiles} file(s)...\n\n`)
|
stdio.write(`Processing {totalFiles} file(s)...\n\n`)
|
||||||
|
|
||||||
for _, filePath in pairs(filesToProcess) do
|
for _, filePath in pairs(filesToProcess) do
|
||||||
processedFiles = processedFiles + 1
|
processedFiles = processedFiles + 1
|
||||||
|
|
||||||
if fs.isFile(filePath) then
|
if fs.isFile(filePath) then
|
||||||
if directoryMode or isValidModelFile(filePath) then
|
if forceBinaryRead or directoryMode or isValidModelFile(filePath) then
|
||||||
local success, result = pcall(function()
|
local success, result = pcall(function()
|
||||||
local fileContents = fs.readFile(filePath)
|
local fileContents = fs.readFile(filePath)
|
||||||
return fileContainsWorkspace(fileContents)
|
return fileContainsWorkspace(fileContents)
|
||||||
|
|||||||
Reference in New Issue
Block a user