Skip to content

Commit

Permalink
Corrected a few mistakes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sago007 committed Sep 2, 2016
1 parent 279d04d commit 9ad3df5
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PKG_CONFIG=$(CROSS)pkg-config
endif

BASE_LIBS=
BASE_CFLAGS=-c -g -O2 -Wall -pedantic-errors
BASE_CFLAGS=-c -g -O2 -Wall -Wextra -pedantic-errors

#The files should compile on both C++03 and C++11
ifdef TESTCPP11
Expand Down
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,21 @@ This sample program gets all folders from the system:
#include <iostream>
#include "sago/platform_folders.h"
using namespace std;
using namespace sago;
using std::cout;
int main()
{
cout << "Config: " << getConfigHome() << endl;
cout << "Data: " << getDataHome() << endl;
cout << "Cache: " << getCacheDir() << endl;
PlatformFolders p;
cout << "Documents: " << p.getDocumentsFolder() << endl;
cout << "Desktop: " << p.getDesktopFolder() << endl;
cout << "Pictures: " << p.getPicturesFolder() << endl;
cout << "Music: " << p.getMusicFolder() << endl;
cout << "Video: " << p.getVideoFolder() << endl;
cout << "Download: " << p.getDownloadFolder1() << endl;
cout << "Save Games 1: " << p.getSaveGamesFolder1() << endl;
cout << "Config: " << sago::getConfigHome() << "\n";
cout << "Data: " << sago::getDataHome() << "\n";
cout << "Cache: " << sago::getCacheDir() << "\n";
sago::PlatformFolders p;
cout << "Documents: " << p.getDocumentsFolder() << "\n";
cout << "Desktop: " << p.getDesktopFolder() << "\n";
cout << "Pictures: " << p.getPicturesFolder() << "\n";
cout << "Music: " << p.getMusicFolder() << "\n";
cout << "Video: " << p.getVideoFolder() << "\n";
cout << "Download: " << p.getDownloadFolder1() << "\n";
cout << "Save Games 1: " << p.getSaveGamesFolder1() << "\n";
return 0;
}
```
Expand Down
30 changes: 16 additions & 14 deletions platform_folders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,23 @@
#include <iostream>
#include "sago/platform_folders.h"

using namespace std;
using namespace sago;

int main()
{
cout << "Config: " << getConfigHome() << endl;
cout << "Data: " << getDataHome() << endl;
cout << "Cache: " << getCacheDir() << endl;
PlatformFolders p;
cout << "Documents: " << p.getDocumentsFolder() << endl;
cout << "Desktop: " << p.getDesktopFolder() << endl;
cout << "Pictures: " << p.getPicturesFolder() << endl;
cout << "Music: " << p.getMusicFolder() << endl;
cout << "Video: " << p.getVideoFolder() << endl;
cout << "Download: " << p.getDownloadFolder1() << endl;
cout << "Save Games 1: " << p.getSaveGamesFolder1() << endl;
std::cout << "Config: " << sago::getConfigHome() << "\n";
std::cout << "Data: " << sago::getDataHome() << "\n";
std::cout << "Cache: " << sago::getCacheDir() << "\n";
sago::PlatformFolders p;
std::cout << "Documents: " << p.getDocumentsFolder() << "\n";
std::cout << "Desktop: " << p.getDesktopFolder() << "\n";
std::cout << "Pictures: " << p.getPicturesFolder() << "\n";
std::cout << "Music: " << p.getMusicFolder() << "\n";
std::cout << "Video: " << p.getVideoFolder() << "\n";
std::cout << "Download: " << p.getDownloadFolder1() << "\n";
std::cout << "Save Games 1: " << p.getSaveGamesFolder1() << "\n";
std::vector<std::string> extraData;
sago::appendAdditionalDataDirectories(extraData);
for (size_t i=0; i < extraData.size(); ++i) {
std::cout << "Additional data " << i << ": " << extraData.at(i) << "\n";
}
return 0;
}
4 changes: 2 additions & 2 deletions sago/platform_folders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ static std::string getLinuxFolderDefault(const char* envName, const char* defaul
}

static void appendExtraFoldersTokenizer(const char* envName, const char* envValue, std::vector<std::string>& folders) {
std::vector<char> buffer(envValue, envValue + strlen(envValue));
std::vector<char> buffer(envValue, envValue + strlen(envValue) + 1);
char *saveptr;
const char* p = strtok_r (buffer.data(), ":", &saveptr);
const char* p = strtok_r ( &buffer[0], ":", &saveptr);
while (p != NULL) {
if (p[0] == '/') {
folders.push_back(p);
Expand Down
8 changes: 4 additions & 4 deletions sago/platform_folders.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ void appendAdditionalDataDirectories(std::vector<std::string>& homes);
* This does not normally include the path returned by GetConfigHome().
* If you want all the folders you should do something like:
* @code{.cpp}
* vector<string> folders;
* folders.push_back(getConfigHome());
* appendAdditionalConfigDirectories(folders);
* for (string s& : folders) {
* std::vector<std::string> folders;
* folders.push_back(sago::getConfigHome());
* sago::appendAdditionalConfigDirectories(folders);
* for (std::string s& : folders) {
* s+="/My Program Name/";
* }
* @endcode
Expand Down

0 comments on commit 9ad3df5

Please sign in to comment.