Skip to content

Commit

Permalink
replaces Poco:File usage with ofFilePath
Browse files Browse the repository at this point in the history
  • Loading branch information
danomatika committed Nov 10, 2011
1 parent 627448a commit 16a888d
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/ofxPd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "ofUtils.h"

#include <algorithm>
#include <Poco/Path.h>

// needed for libpd audio passing
#define USEAPI_DUMMY
Expand Down Expand Up @@ -92,9 +91,9 @@ void ofxPd::clear() {

//--------------------------------------------------------------------
void ofxPd::addToSearchPath(const std::string& path) {
Poco::Path fullPath(ofToDataPath(path));
string fullpath = ofFilePath::getAbsolutePath(ofToDataPath(path));
_LOCK();
PdBase::addToSearchPath(fullPath.toString().c_str());
PdBase::addToSearchPath(fullpath.c_str());
_UNLOCK();
}

Expand All @@ -105,28 +104,21 @@ void ofxPd::clearSearchPath() {
}

//--------------------------------------------------------------------
//
// references http://pocoproject.org/docs/Poco.Path.html
//
Patch ofxPd::openPatch(const std::string& patch) {

Poco::Path path(ofToDataPath(patch));
string folder = path.parent().toString();
string fullpath = ofFilePath::getAbsolutePath(ofToDataPath(patch));
string file = ofFilePath::getFileName(fullpath);
string folder = ofFilePath::getEnclosingDirectory(fullpath);

// trim the trailing slash Poco::Path always adds ... blarg
if(folder.size() > 0 && folder.at(folder.size()-1) == '/') {
folder.erase(folder.end()-1);
}

ofLog(OF_LOG_VERBOSE, "Pd: Opening patch: "+path.getFileName()+
ofLog(OF_LOG_VERBOSE, "Pd: Opening patch: "+file+
" path: "+folder);

// [; pd open file folder(
_LOCK();
Patch p = PdBase::openPatch(path.getFileName().c_str(), folder.c_str());
Patch p = PdBase::openPatch(file.c_str(), folder.c_str());
_UNLOCK();
if(!p.isValid()) {
ofLog(OF_LOG_ERROR, "Pd: Opening patch \"%s\" failed", path.getFileName().c_str());
ofLog(OF_LOG_ERROR, "Pd: Opening patch \"%s\" failed", file.c_str());
}

return p;
Expand Down

0 comments on commit 16a888d

Please sign in to comment.