Skip to content

Commit

Permalink
Finally fixed pathing issue related to windows utf8 to wide char conv…
Browse files Browse the repository at this point in the history
…ersion in Luajit.
  • Loading branch information
David Lannan committed Sep 20, 2022
1 parent 20092b8 commit 6c2ae75
Show file tree
Hide file tree
Showing 4 changed files with 1,288 additions and 3 deletions.
Binary file modified blender/addons/defender.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion blender/addons/defender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"name": "Defender",
"description": "Sync a Blender Scene directly to Defold resources",
"author": "dlannan",
"version": (1, 1, 1),
"version": (1, 2, 0),
"blender": (2, 80, 0),
"location": "3D View > Defold",
"warning": "", # used for warning icon and text in addons panel
Expand Down
17 changes: 15 additions & 2 deletions blender/addons/defender/defoldsync/generator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,21 @@ local CMD_COPY = "cp"
local CMD_MKDIR = "mkdir -p"
local platform = ffi.os

-- Dummy holder for path conversion for file opens
local convertPath = function(str) return str end

-- The system OS name: "Darwin", "Linux", "Windows", "HTML5", "Android" or "iPhone OS"
if platform == "Windows" then
print("Windows Platform detected.")
local convert_from_utf8 = require("defoldsync.utf8_filenames")

PATH_SEPARATOR = "\\"
CMD_COPY = "copy /y"
CMD_MKDIR = "mkdir"

convertPath = function( str )
return convert_from_utf8(str)
end
end

local WHITE_PNG = "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A\x00\x00\x00\x0D\x49\x48\x44\x52\x00\x00\x00\x10\x00\x00\x00\x10\x08\x02\x00\x00\x00\x90\x91\x68\x36\x00\x00\x02\xDE\x7A\x54\x58\x74\x52\x61\x77\x20\x70\x72\x6F\x66\x69\x6C\x65\x20\x74\x79\x70\x65\x20\x65\x78\x69\x66\x00\x00\x78\xDA\xED\x97\x5D\x72\xE5\x28\x0C\x85\xDF\x59\xC5\x2C\x01\x49\x08\x89\xE5\x60\x30\x55\xBD\x83\x59\xFE\x1C\x30\xD7\xC9\xBD\x49\x77\xD5\xF4\xF4\xC3\x3C\x5C\x13\xF3\x23\xCB\x07\xD0\x27\x93\x24\x9C\x7F\xFF\x18\xE1\x2F\x5C\x54\x24\x86\xA4\xE6\xB9\xE4\x1C\x71\xA5\x92\x0A\x57\x74\x3C\x5E\xD7\xD5\x52\x4C\xAB\xDE\x83\xF8\xE8\x3C\xD9\xC3\xFD\x80\x61\x12\xB4\x72\x0D\xF3\xB9\xFD\x2B\xEC\xFA\xF1\x82\xA5\x6D\x3F\x9E\xED\xC1\xDA\xD6\xF1\x2D\xF4\x50\xDE\x82\x32\x67\x66\x74\xB6\x9F\x6F\x21\xE1\xCB\x4E\x7B\x1C\xCA\x7E\xAF\xA6\x4F\xDB\xD9\xF7\x68\xBC\x1E\xEB\x71\x3D\x7A\x1D\x27\x43\x30\xBA\x42\x4F\x38\xF0\x29\x24\x11\xB5\xCF\x59\x64\xDE\x24\x15\x37\xA3\xC6\x78\x3A\x89\xA0\x1F\xA5\xAC\x9A\xBE\x8F\x5D\xB8\xBB\x2F\xC1\xBB\x7B\x2F\xB1\x8B\x75\xDB\xE5\x39\x14\x21\xE6\xED\x90\x5F\x62\xB4\xED\xA4\xDF\xC7\x6E\x45\xE8\x85\xDA\x63\xE6\xA7\x07\x26\xF7\x14\x5F\x63\x37\xBA\x8F\x71\x5E\xBB\xAB\x29\x23\x52\x39\xEC\x4D\x3D\xB6\xB2\x7A\x70\x44\x38\x93\xAC\xD7\x32\x8A\xE1\x56\xF4\x6D\x95\x82\xE2\xD8\x62\x03\xB1\x0E\x9A\x07\x4A\x0B\x54\x88\x11\xED\x41\x89\x3A\x55\x1A\x74\xAE\xB6\x51\xC3\x12\x13\x9F\x6C\x68\x99\x1B\x18\x4C\x9B\x8B\x71\xE1\x36\x83\x2E\x69\x16\x1A\x6C\xC0\xD0\x83\x38\xA8\x34\x50\x13\x98\xF9\x5E\x0B\xAD\x79\xCB\x9A\xAF\x91\x63\xE6\x4E\xF0\x64\x82\xD8\x24\xFA\xA5\x84\xEF\x8C\xBF\x53\x6E\xA1\x31\x66\xEA\x12\x45\xBF\x63\x85\x75\xF1\xCC\x69\x2C\x63\x92\x9B\x35\xBC\x00\x84\xC6\x8E\xA9\xAE\xF8\xAE\x12\x3E\xE5\x4D\xFC\x04\x56\x40\x50\x57\x98\x1D\x1B\xAC\xF1\xB8\x24\x0E\xA5\x8F\xDC\x92\xC5\x59\xE0\xA7\x31\x85\x78\x7D\x1A\x64\x7D\x0B\x20\x44\x98\x5B\xB1\x18\x12\x10\x88\x99\x44\x29\x53\x34\x66\x23\x42\x1C\x1D\x7C\x2A\x56\xCE\x92\xF8\x00\x01\x52\xE5\x4E\x61\x80\x8D\x48\x06\x1C\xE7\x39\x37\xDE\x31\x5A\xBE\xAC\x7C\x99\x71\xB4\x00\x84\x4A\x16\x03\x1A\x7C\x28\x80\x95\x92\x22\x7F\x2C\x39\x72\xA8\xAA\x68\x0A\xAA\x9A\xD5\xD4\xB5\x68\xCD\x92\x53\xD6\x9C\xB3\xE5\x79\x46\x55\x13\x4B\xA6\x96\xCD\xCC\xAD\x58\x75\xF1\xE4\xEA\xD9\xCD\xDD\x8B\xD7\xC2\x45\x70\x84\x69\xC9\xC5\x42\xF1\x52\x4A\xAD\x98\xB4\x42\xBA\xE2\xED\x0A\x8F\x5A\x0F\x3E\xE4\x48\x87\x1E\xF9\xB0\xC3\x8F\x72\xD4\x86\xF4\x69\xA9\x69\xCB\xCD\x9A\xB7\xD2\x6A\xE7\x2E\x1D\x9F\x7F\xCF\xDD\x42\xF7\x5E\x7A\x3D\xE9\x44\x2A\x9D\xE9\xD4\x33\x9F\x76\xFA\x59\xCE\x3A\x90\x6B\x43\x46\x1A\x3A\xF2\xB0\xE1\xA3\x8C\x7A\x53\xDB\x54\x9F\xA9\xD1\x0B\xB9\x5F\x53\xA3\x4D\x6D\x12\x4B\xCB\xCF\x3E\xA8\xC1\x6C\xF6\x90\xA0\x79\x9C\xE8\x64\x06\x62\x9C\x08\xC4\x6D\x12\x40\x42\xF3\x64\x16\x9D\x52\xE2\x49\x6E\x32\x8B\x65\x1E\x57\xCA\xA0\x46\x3A\xE1\x74\x9A\xC4\x40\x30\x9D\xC4\x3A\xE8\x66\xF7\x41\xEE\x97\xDC\x82\xA6\x7F\xC5\x8D\x7F\x46\x2E\x4C\x74\x7F\x82\x5C\x98\xE8\x36\xB9\xAF\xDC\xBE\xA1\xD6\xEB\xFA\x8D\x22\x0B\xD0\xFC\x0A\x67\x4C\xA3\x0C\x1C\x6C\x70\xAA\xEC\xF8\xC1\x79\xFC\xFB\x6D\xF8\xAF\x02\x6F\xA1\xB7\xD0\x5B\xE8\x2D\xF4\x16\x7A\x0B\xBD\x85\xFE\x37\x42\x32\xF0\xC7\x03\xFE\x77\x0C\xFF\x00\x42\xA5\x91\xC8\x8A\x21\x2A\xB7\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x2E\x23\x00\x00\x2E\x23\x01\x78\xA5\x3F\x76\x00\x00\x00\x07\x74\x49\x4D\x45\x07\xE5\x0C\x14\x0C\x27\x01\x34\x0E\x76\xCF\x00\x00\x00\x1A\x49\x44\x41\x54\x28\xCF\x63\xFC\xFF\xFF\x3F\x03\x29\x80\x89\x81\x44\x30\xAA\x61\x54\xC3\xD0\xD1\x00\x00\x55\x6D\x03\x1D\x9F\x2E\x15\xA2\x00\x00\x00\x00\x49\x45\x4E\x44\xAE\x42\x60\x82"
Expand Down Expand Up @@ -426,7 +435,7 @@ local function localpathname( inpath )
-- Subtract project path from pathname
local newpath = nil
if(idx > 1) then newpath = string.sub(inpath, idx, -1) end
print(inpath, newpath)

-- Local path should always use /
if(newpath) then newpath = string.gsub(newpath, "\\", "/") end
return newpath or inpath
Expand Down Expand Up @@ -458,7 +467,10 @@ local function makefolders( collectionname, base, config )
assert(collectionname ~= nil, "Invalid collectionname")
assert(base ~= nil, "Invalid Base path string.")

gendata.base = base
if platform == "Windows" then
base = convertPath( base )
end
gendata.base = base
gendata.config = config
local collectionpath = base..PATH_SEPARATOR..collectionname

Expand Down Expand Up @@ -714,6 +726,7 @@ local function makegofile( name, filepath, go )
if(meshurl) then
local meshfilepath = ""
local meshpath = string.gsub( meshurl, "\\", "\\\\" )

local fh = io.open( meshpath, "rb" )
if(fh) then
local fdata = fh:read("*all")
Expand Down
Loading

0 comments on commit 6c2ae75

Please sign in to comment.