Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKalle-Samuli Riihikoski <haikalle@gmail.com>2020-11-22 15:17:47 +0300
committerKalle-Samuli Riihikoski <haikalle@gmail.com>2020-11-22 15:17:47 +0300
commitb4ca385ac92d1ab362a503760a0622b5774ea2cb (patch)
tree6dbbd380883e5331bba90ceb0ed7a4a20f57c46f /io_coat3D
parent860f646176dce129e4ab78676626e4b453505355 (diff)
io_coat3D: fixing exchange_folder.txt bug
Diffstat (limited to 'io_coat3D')
-rw-r--r--io_coat3D/__init__.py12
-rw-r--r--io_coat3D/folders.py40
2 files changed, 32 insertions, 20 deletions
diff --git a/io_coat3D/__init__.py b/io_coat3D/__init__.py
index a5f28246..d766ffc7 100644
--- a/io_coat3D/__init__.py
+++ b/io_coat3D/__init__.py
@@ -45,6 +45,7 @@ import ntpath
import re
import shutil
import pathlib
+import stat
import time
@@ -266,8 +267,15 @@ class SCENE_OT_folder(bpy.types.Operator):
coat3D = bpy.context.scene.coat3D
if(os.path.isdir(coat3D.exchangeFolder)):
foundExchangeFolder= True
- else:
- foundExchangeFolder = False
+ if(platform == 'win32' or platform == 'darwin'):
+ exchangeFile = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender' + os.sep + '3DC2Blender'
+ else:
+ exchangeFile = os.path.expanduser("~") + os.sep + '3DC2Blender' + os.sep + '3DC2Blender'
+
+ if(coat3D.exchangeFolder.rfind('Exchange') >= 0):
+ file = open(exchangeFile, 'w')
+ file.write(coat3D.exchangeFolder)
+ file.close()
return {'FINISHED'}
diff --git a/io_coat3D/folders.py b/io_coat3D/folders.py
index b0594786..36471b98 100644
--- a/io_coat3D/folders.py
+++ b/io_coat3D/folders.py
@@ -14,26 +14,30 @@ def InitFolders():
# 1. #################################################################
if(platform == 'win32' or platform == 'darwin'):
- exchangeFile = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender' + os.sep + 'Exchange_folder.txt'
+ DC2Folder = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender'
else:
- exchangeFile = os.path.expanduser("~") + os.sep + '3DC2Blender' + os.sep + 'Exchange_folder.txt'
- if(os.path.isfile(exchangeFile)):
- folderPath = ''
+ DC2Folder = os.path.expanduser("~") + os.sep + '3DC2Blender'
+
+ exchangeFolderFile = DC2Folder + os.sep + 'Exchange_folder.txt'
- folderPathh = open(exchangeFile)
- for line in folderPathh:
- folderPath = line
+ if(not os.path.isdir(DC2Folder)):
+ os.mkdir(DC2Folder)
+
+ if(not os.path.isfile(exchangeFolderFile)):
+ file = open(exchangeFolderFile, 'w')
+ file.close()
+ else:
+ savedExchangePath = ''
+ folderPath = open(exchangeFolderFile)
+
+ for line in folderPath:
+ savedExchangePath = line
break
- folderPathh.close()
+ folderPath.close()
- if(os.path.isdir(os.path.abspath(folderPath)) and folderPath.rfind('Exchange') >= 0):
- coat3D.exchangeFolder = folderPath
+ if(os.path.isdir(os.path.abspath(savedExchangePath)) and savedExchangePath.rfind('Exchange') >= 0):
+ coat3D.exchangeFolder = savedExchangePath
return True, coat3D.exchangeFolder
- else:
- try:
- os.makedirs(os.path.dirname(exchangeFile))
- except:
- pass
# 2. #################################################################
@@ -50,7 +54,7 @@ def InitFolders():
Blender_folder = ("%s%sBlender"%(exchangeFolder,os.sep))
if(not(os.path.isdir(Blender_folder))):
- os.makedirs(Blender_folder)
+ os.makedirs(Blender_folder, mode = 0o666)
Blender_folder1 = os.path.join(Blender_folder,"run.txt")
file = open(Blender_folder1, "w")
file.close()
@@ -101,13 +105,13 @@ def set_working_folders():
else:
folder_objects = os.path.expanduser("~") + os.sep + 'Documents' + os.sep + '3DC2Blender' + os.sep + 'ApplinkObjects'
if(not(os.path.isdir(folder_objects))):
- os.makedirs(folder_objects)
+ os.makedirs(folder_objects, mode = 0o666)
else:
if (coat3D.defaultfolder != '' and os.path.isdir(coat3D.defaultfolder)):
return coat3D.defaultfolder
else:
folder_objects = os.path.expanduser("~") + os.sep + '3DC2Blender' + os.sep + 'ApplinkObjects'
if(not(os.path.isdir(folder_objects))):
- os.makedirs(folder_objects)
+ os.makedirs(folder_objects, mode = 0o666)
return folder_objects