Skip to content

Commit

Permalink
v0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
d3cod3 committed Oct 1, 2018
1 parent 88cebbc commit be26745
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 10 deletions.
18 changes: 13 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@
```

```bash
___ _ ____
/ _ \ / | |___ \
| | | || | __) |
| |_| || |_ / __/
\___(_)_(_)_____|
___ _ _____
/ _ \ / | |___ /
| | | || | |_ \
| |_| || |_ ___) |
\___(_)_(_)____/

```

# v0.1.3

### general
+ Fixed macOS Sierra & High Sierra Gatekeeper Path Randomization Anti-Malware Feature Issue

//////////////////////////////////

# v0.1.2

### general
Expand Down
4 changes: 4 additions & 0 deletions bin/data/DO_NOT_TOUCH_THIS_FOLDER_README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Due to Gatekeeper Path Randomization Anti-Malware Feature starting from macOS Sierra, and anticipating future headaches,
Mosaic data assets are copied in the user home Documents folder ($HOME/Documents/Mosaic/data).

So in order to avoid any problem with Mosaic software, NEVER TOUCH THE CONTENT OF THIS FOLDER!!!
1 change: 1 addition & 0 deletions bin/data/release.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.3
4 changes: 2 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
#pragma mark once

#define PACKAGE "Mosaic"
#define VERSION "0.1.0"
#define VERSION "0.1.3"
#define DESCRIPTION "OF Visual Patching Developer Platform"
#define TAGS "mosaic,openframeworks,macos,linux,windows,creative-coding,video,audio,graphics,live-coding,visual-programming,creative-coding,transmedia"

#define WINDOW_TITLE "Mosaic 0.1.0"
#define WINDOW_TITLE "Mosaic 0.1.3"
#define WINDOW_START_WIDTH 1280
#define WINDOW_START_HEIGHT 720

Expand Down
92 changes: 89 additions & 3 deletions src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void ofApp::setup(){
ofSetVerticalSync(true);
ofSetDrawBitmapMode(OF_BITMAPMODE_SIMPLE);
ofSetLogLevel("Mosaic",OF_LOG_NOTICE);
initDataFolderFromBundle();
///////////////////////////////////////////

// RETINA FIX
Expand All @@ -56,7 +57,7 @@ void ofApp::setup(){
numFiles = 0;
numLines = 0;

projectDirectory.listDir(ofToDataPath("../../src/"));
/*projectDirectory.listDir(ofToDataPath("../../src/"));
recursiveScanDirectory(projectDirectory);
projectDirectory.listDir(ofToDataPath("../../../../../addons/ofxVisualProgramming/"));
recursiveScanDirectory(projectDirectory);
Expand All @@ -67,7 +68,7 @@ void ofApp::setup(){
for (auto line : buffer.getLines()){
numLines++;
}
}
}*/

// LOGGER
isInited = false;
Expand All @@ -87,7 +88,7 @@ void ofApp::setup(){
screenLoggerChannel->setPrefixTimestamp(true);

ofLog(OF_LOG_NOTICE,"%s | %s",WINDOW_TITLE,DESCRIPTION);
ofLog(OF_LOG_NOTICE,"%i files and %i code lines",numFiles,numLines);
//ofLog(OF_LOG_NOTICE,"%i files and %i code lines",numFiles,numLines);
ofLog(OF_LOG_NOTICE," ");

// Visual Programming Environment Load
Expand Down Expand Up @@ -335,3 +336,88 @@ void ofApp::recursiveScanDirectory(ofDirectory dir){
}
}
}

//--------------------------------------------------------------
void ofApp::initDataFolderFromBundle(){
string _bundleDataPath;
#ifdef TARGET_LINUX
_bundleDataPath = ofToDataPath("",true);
#elif defined(TARGET_OSX)
CFURLRef appUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFStringRef appPath = CFURLCopyFileSystemPath(appUrl, kCFURLPOSIXPathStyle);

const CFIndex kCStringSize = 128;
char temporaryCString[kCStringSize];
bzero(temporaryCString,kCStringSize);
CFStringGetCString(appPath, temporaryCString, kCStringSize, kCFStringEncodingUTF8);
std::string *appPathStr = new std::string(temporaryCString);
CFRelease(appUrl);
CFRelease(appPath);

CFURLRef resourceUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
CFStringRef resourcePath = CFURLCopyFileSystemPath(resourceUrl, kCFURLPOSIXPathStyle);

bzero(temporaryCString,kCStringSize);
CFStringGetCString(resourcePath, temporaryCString, kCStringSize, kCFStringEncodingUTF8);
std::string *resourcePathStr = new std::string(temporaryCString);
CFRelease(resourcePath);
CFRelease(resourceUrl);

_bundleDataPath = *appPathStr + "/" + *resourcePathStr + "/"; // the absolute path to the resources folder
#elif defined(TARGET_WIN32)
_bundleDataPath = ofToDataPath("",true);
#endif

const char *homeDir = getenv("HOME");

if(!homeDir){
struct passwd* pwd;
#ifdef TARGET_WIN32
char buffer[UNLEN + 1] = {0};
DWORD buffer_len = UNLEN + 1;
if (!::GetUserNameA(buffer, & buffer_len)){
ofLog(OF_LOG_ERROR,"Error accessing user home folder!");
}
pwd = getpwuid(buffer);
#elif defined(TARGET_OSX) || defined(TARGET_LINUX)
pwd = getpwuid(getuid());
#endif
if (pwd){
homeDir = pwd->pw_dir;
}
}

string _MosaicDataPath(homeDir);
_MosaicDataPath += "/Documents/Mosaic/data";

std::filesystem::path mosaicPath(_MosaicDataPath.c_str());

ofDirectory mosaicDir;

if(!mosaicDir.doesDirectoryExist(mosaicPath)){
mosaicDir.createDirectory(mosaicPath,true,true);

std::filesystem::path dataPath(_bundleDataPath.c_str());

ofDirectory dataDir(dataPath);
dataDir.copyTo(mosaicPath,true,true);
}else{
string relfilepath = _MosaicDataPath+"/release.txt";
std::filesystem::path releasePath(relfilepath.c_str());
ofFile relFile(releasePath);

if(relFile.exists()){
string actualRel = relFile.readToBuffer().getText();

if(VERSION != actualRel){
std::filesystem::path dataPath(_bundleDataPath.c_str());

ofDirectory dataDir(dataPath);
dataDir.copyTo(mosaicPath,true,true);
}
}

}

ofSetDataPathRoot(mosaicPath); // tell OF to look for resources here
}
4 changes: 4 additions & 0 deletions src/ofApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@

#pragma once

#include <pwd.h>
#include <unistd.h>

#include "ofMain.h"

#include "config.h"
Expand Down Expand Up @@ -73,6 +76,7 @@ class ofApp : public ofBaseApp{

// UTILS
void recursiveScanDirectory(ofDirectory dir);
void initDataFolderFromBundle();

// Command line arguments
vector<string> arguments;
Expand Down

0 comments on commit be26745

Please sign in to comment.