Skip to content

Commit a9f091d

Browse files
authored
more fs::path in ofCore (#8117)
1 parent c7879c9 commit a9f091d

File tree

9 files changed

+31
-32
lines changed

9 files changed

+31
-32
lines changed

libs/openFrameworks/communication/ofArduino.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1517,7 +1517,9 @@ void ofArduino::sendOneWireRequest(int pin, unsigned char subcommand, vector<un
15171517

15181518
if (correlationId) {
15191519
bytes[10] = correlationId & 0xFF;
1520-
bytes[11] = (correlationId >> 8) & 0xFF;
1520+
// Doesn't make sense. uint8_t >> 8 will always be zero.
1521+
// bytes[11] = (correlationId >> 8) & 0xFF;
1522+
bytes[11] = 0;
15211523
}
15221524

15231525
if (delay > 0) {

libs/openFrameworks/graphics/ofGraphicsCairo.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ static void ofEndSaveScreen(){
2727

2828
}
2929

30-
static void ofBeginSaveScreen(const of::filesystem::path & filename, ofCairoRenderer::Type type, bool bMultipage, bool b3D, ofRectangle outputsize){
30+
static void ofBeginSaveScreen(const of::filesystem::path & fileName, ofCairoRenderer::Type type, bool bMultipage, bool b3D, ofRectangle outputsize){
3131
if( bScreenShotStarted ) ofEndSaveScreen();
3232

3333
storedRenderer = ofGetCurrentRenderer();
3434

3535
cairoScreenshot = std::make_unique<ofCairoRenderer>();
36-
cairoScreenshot->setup(filename, type, bMultipage, b3D, outputsize);
36+
cairoScreenshot->setup(fileName, type, bMultipage, b3D, outputsize);
3737

3838
rendererCollection = std::make_shared<ofRendererCollection>();
3939
rendererCollection->renderers.push_back(storedRenderer);
@@ -45,8 +45,8 @@ static void ofBeginSaveScreen(const of::filesystem::path & filename, ofCairoRend
4545
}
4646

4747
//-----------------------------------------------------------------------------------
48-
void ofBeginSaveScreenAsPDF(const of::filesystem::path & filename, bool bMultipage, bool b3D, ofRectangle outputsize){
49-
ofBeginSaveScreen(filename, ofCairoRenderer::PDF, bMultipage, b3D, outputsize);
48+
void ofBeginSaveScreenAsPDF(const of::filesystem::path & fileName, bool bMultipage, bool b3D, ofRectangle outputsize){
49+
ofBeginSaveScreen(fileName, ofCairoRenderer::PDF, bMultipage, b3D, outputsize);
5050
}
5151

5252
//-----------------------------------------------------------------------------------
@@ -55,8 +55,8 @@ void ofEndSaveScreenAsPDF(){
5555
}
5656

5757
//-----------------------------------------------------------------------------------
58-
void ofBeginSaveScreenAsSVG(const of::filesystem::path & filename, bool bMultipage, bool b3D, ofRectangle outputsize){
59-
ofBeginSaveScreen(filename, ofCairoRenderer::SVG, bMultipage, b3D, outputsize);
58+
void ofBeginSaveScreenAsSVG(const of::filesystem::path & fileName, bool bMultipage, bool b3D, ofRectangle outputsize){
59+
ofBeginSaveScreen(fileName, ofCairoRenderer::SVG, bMultipage, b3D, outputsize);
6060
}
6161

6262
//-----------------------------------------------------------------------------------

libs/openFrameworks/graphics/ofGraphicsCairo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
/// ~~~~
2525
/// \sa End drawing with ofEndSaveScreenAsPDF()
2626
///
27-
void ofBeginSaveScreenAsPDF(const of::filesystem::path & filename, bool bMultipage = false, bool b3D = false, ofRectangle outputsize = ofRectangle(0,0,0,0));
27+
void ofBeginSaveScreenAsPDF(const of::filesystem::path & fileName, bool bMultipage = false, bool b3D = false, ofRectangle outputsize = ofRectangle(0,0,0,0));
2828

2929
/// \brief Terminates draw to PDF through ofCairoRenderer and outputs the file.
3030
/// \sa ofBeginSaveScreenAsPDF()
3131
void ofEndSaveScreenAsPDF();
3232

3333
/// \brief Begin rendering to a SVG file.
3434
/// \sa ofEndSaveScreenAsSVG(), ofBeginSaveScreenAsPDF()
35-
void ofBeginSaveScreenAsSVG(const of::filesystem::path & filename, bool bMultipage = false, bool b3D = false, ofRectangle outputsize = ofRectangle(0,0,0,0));
35+
void ofBeginSaveScreenAsSVG(const of::filesystem::path & fileName, bool bMultipage = false, bool b3D = false, ofRectangle outputsize = ofRectangle(0,0,0,0));
3636

3737
/// \brief Terminates draw to SVG and outputs the file.
3838
/// \sa ofBeginSaveScreenAsSVG()

libs/openFrameworks/graphics/ofTrueTypeFont.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ static of::filesystem::path winFontPathByName(const string & fontname) {
330330
#ifdef TARGET_LINUX
331331
//------------------------------------------------------------------
332332
static of::filesystem::path linuxFontPathByName(const string & fontname) {
333-
string filename;
333+
of::filesystem::path fontPath;
334334
FcPattern * pattern = FcNameParse((const FcChar8*)fontname.c_str());
335335
FcBool ret = FcConfigSubstitute(0,pattern,FcMatchPattern);
336336
if(!ret){
@@ -346,20 +346,19 @@ static of::filesystem::path linuxFontPathByName(const string & fontname) {
346346
ofLogError() << "linuxFontPathByName(): couldn't match font file or system font with name \"" << fontname << "\"";
347347
FcPatternDestroy(fontMatch);
348348
FcPatternDestroy(pattern);
349-
return "";
349+
return {};
350350
}
351351
FcChar8 *file;
352352
if (FcPatternGetString (fontMatch, FC_FILE, 0, &file) == FcResultMatch){
353-
filename = (const char*)file;
353+
fontPath = (const char*)file;
354354
}else{
355355
ofLogError() << "linuxFontPathByName(): couldn't find font match for \"" << fontname << "\"";
356356
FcPatternDestroy(fontMatch);
357357
FcPatternDestroy(pattern);
358-
return "";
358+
return {};
359359
}
360360
FcPatternDestroy(fontMatch);
361361
FcPatternDestroy(pattern);
362-
of::filesystem::path fontPath = { filename };
363362
return fontPath;
364363
}
365364
#endif

libs/openFrameworks/sound/ofAVEngineSoundPlayer.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ - (float)soundDurationSeconds{
10131013
unload();
10141014
}
10151015

1016-
bool ofAVEngineSoundPlayer::load(const of::filesystem::path& fileName, bool stream) {
1016+
bool ofAVEngineSoundPlayer::load(const of::filesystem::path & fileName, bool stream) {
10171017
if(soundPlayer != NULL) {
10181018
unload();
10191019
}

libs/openFrameworks/sound/ofMediaFoundationSoundPlayer.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,24 +187,22 @@ ofMediaFoundationSoundPlayer::~ofMediaFoundationSoundPlayer() {
187187
}
188188

189189
//--------------------
190-
bool ofMediaFoundationSoundPlayer::load(const of::filesystem::path& fileName, bool stream) {
190+
bool ofMediaFoundationSoundPlayer::load(const of::filesystem::path & fileName, bool stream) {
191191
unload();
192192

193-
// FIXME: wstring?
193+
auto filePath = fileName;
194194
std::string fileStr = ofPathToString(fileName);
195195
bool bStream = false;
196196
bStream = bStream || ofIsStringInString(fileStr, "http://");
197197
bStream = bStream || ofIsStringInString(fileStr, "https://");
198198
bStream = bStream || ofIsStringInString(fileStr, "rtsp://");
199199
bStream = bStream || ofIsStringInString(fileStr, "rtmp://");
200200

201-
of::filesystem::path absPath{ fileStr };
202-
203201
if (!bStream) {
204-
if (ofFile::doesFileExist(absPath)) {
205-
absPath = ofFilePath::getAbsolutePath(absPath, true);
202+
if (ofFile::doesFileExist(filePath)) {
203+
filePath = ofFilePath::getAbsolutePath(filePath, true);
206204
} else {
207-
ofLogError("ofMediaFoundationSoundPlayer") << " file does not exist! " << absPath;
205+
ofLogError("ofMediaFoundationSoundPlayer") << " file does not exist! " << filePath;
208206
return false;
209207
}
210208
}
@@ -224,7 +222,7 @@ bool ofMediaFoundationSoundPlayer::load(const of::filesystem::path& fileName, bo
224222
}
225223

226224

227-
LPCWSTR path = absPath.c_str();
225+
LPCWSTR path = filePath.c_str();
228226

229227

230228
hr = MFCreateSourceReaderFromURL(
@@ -233,12 +231,12 @@ bool ofMediaFoundationSoundPlayer::load(const of::filesystem::path& fileName, bo
233231
mSrcReader.GetAddressOf());
234232

235233
if (hr != S_OK) {
236-
ofLogError("ofMediaFoundationSoundPlayer::load") << " unable to load from: " << absPath;
234+
ofLogError("ofMediaFoundationSoundPlayer::load") << " unable to load from: " << filePath;
237235
unload();
238236
return false;
239237
}
240238

241-
ofLogVerbose("ofMediaFoundationSoundPlayer::load") << " created the source reader " << absPath;
239+
ofLogVerbose("ofMediaFoundationSoundPlayer::load") << " created the source reader " << filePath;
242240
// Select only the audio stream
243241
hr = mSrcReader->SetStreamSelection(MF_SOURCE_READER_ALL_STREAMS, false);
244242
if (hr == S_OK) {

libs/openFrameworks/sound/ofSoundPlayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ std::shared_ptr<ofBaseSoundPlayer> ofSoundPlayer::getPlayer(){
113113
}
114114

115115
//--------------------------------------------------------------------
116-
bool ofSoundPlayer::load(const of::filesystem::path& fileName, bool stream){
116+
bool ofSoundPlayer::load(const of::filesystem::path & fileName, bool stream){
117117
if( player ){
118118
return player->load(fileName, stream);
119119
}

libs/openFrameworks/utils/ofUtils.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,18 +1023,18 @@ std::string ofGetVersionPreRelease() {
10231023
//from the forums http://www.openframeworks.cc/forum/viewtopic.php?t=1413
10241024

10251025
//--------------------------------------------------
1026-
void ofSaveScreen(const of::filesystem::path & filename) {
1026+
void ofSaveScreen(const of::filesystem::path & fileName) {
10271027
/*ofImage screen;
10281028
screen.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR);
10291029
screen.grabScreen(0, 0, ofGetWidth(), ofGetHeight());
10301030
screen.save(filename);*/
10311031
ofPixels pixels;
10321032
ofGetGLRenderer()->saveFullViewport(pixels);
1033-
ofSaveImage(pixels, filename);
1033+
ofSaveImage(pixels, fileName);
10341034
}
10351035

10361036
//--------------------------------------------------
1037-
void ofSaveViewport(const of::filesystem::path & filename) {
1037+
void ofSaveViewport(const of::filesystem::path & fileName) {
10381038
// because ofSaveScreen doesn't related to viewports
10391039
/*ofImage screen;
10401040
ofRectangle view = ofGetCurrentViewport();
@@ -1044,13 +1044,13 @@ void ofSaveViewport(const of::filesystem::path & filename) {
10441044

10451045
ofPixels pixels;
10461046
ofGetGLRenderer()->saveFullViewport(pixels);
1047-
ofSaveImage(pixels, filename);
1047+
ofSaveImage(pixels, fileName);
10481048
}
10491049

10501050
//--------------------------------------------------
10511051
int saveImageCounter = 0;
10521052
void ofSaveFrame(bool bUseViewport) {
1053-
string fileName = ofToString(saveImageCounter) + ".png";
1053+
of::filesystem::path fileName = ofToString(saveImageCounter) + ".png";
10541054
if (bUseViewport) {
10551055
ofSaveViewport(fileName);
10561056
} else {

libs/openFrameworks/utils/ofUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ std::string ofGetVersionPreRelease();
12351235
/// The output file type will be deduced from the given file name.
12361236
///
12371237
/// \param filename The image output file.
1238-
void ofSaveScreen(const of::filesystem::path & filename);
1238+
void ofSaveScreen(const of::filesystem::path & fileName);
12391239

12401240
/// \brief Saves the current frame as a PNG image.
12411241
///

0 commit comments

Comments
 (0)