Skip to content

Commit

Permalink
Added quick test script to compile both C++03, C++11 and Windows. Win…
Browse files Browse the repository at this point in the history
…dows now always uses ANSI strings for portability.

Updated README to reflect this.
  • Loading branch information
sago007 committed Sep 20, 2015
1 parent 043fcfb commit 63627d7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ O_FILES=${PROGRAMNAME}.o sago/platform_folders.o
total: ${PROGRAMNAME}.out

clean:
rm -f */*.o *.o *.P */*.P ${PROGRAMNAME}
rm -f */*.o *.o *.P */*.P ${PROGRAMNAME}.out

${PROGRAMNAME}.out: $(O_FILES)
$(CXX) -O -o ${PROGRAMNAME}.out $(O_FILES) $(BASE_LIBS)
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,24 @@ Download: /home/poul/Hentede filer
Save Games 1: /home/poul/.local/share
```

On Windows it could be:
```
Config: C:\users\poul\Application Data
Data: C:\users\poul\Application Data
Cache: C:\users\poul\Local Settings\Application Data
Documents: C:\users\poul\Mine dokumenter
Desktop: C:\users\poul\Skrivebord
Pictures: C:\users\poul\Mine Billeder
Music: C:\users\poul\Min Musik
Video: C:\users\poul\Mine Film
Download: C:\users\poul\Skrivebord
Save Games 1: C:\users\poul\Mine dokumenter\My Games
```

# Encoding
For Windows ANSI encoding is always used. Microsoft's implementation of "Unicode" is simply not compatible with platform independent code.
For all other systems the local encoding is used. For most systems this is UTF-8.
Generally you should only append simple ASCII chars to the paths.

# Licence
Provided under the MIT license for the same reason XDG is licenced under it. So that you can quickly copy-paste the methods you need or just include the "sago"-folder.
12 changes: 12 additions & 0 deletions compile_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /bin/bash
set -e
#This script will attempt to compile with C++11, cross compile to windows with C++11, cross compile to windows with C++03, compile with C++03
make clean
make TESTCPP11=1
make clean
make CROSS=i686-pc-mingw32- TESTCPP11=1
make clean
make CROSS=i686-pc-mingw32-
mv platform_folders.out platform_folders.exe
make clean
make
2 changes: 1 addition & 1 deletion sago/platform_folders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
static std::string GetWindowsFolder(int folderId, const char* errorMsg) {
char szPath[MAX_PATH];
szPath[0] = 0;
if ( !SUCCEEDED( SHGetFolderPath( NULL, folderId, NULL, 0, szPath ) ) )
if ( !SUCCEEDED( SHGetFolderPathA( NULL, folderId, NULL, 0, szPath ) ) )
{
throw std::runtime_error(errorMsg);
}
Expand Down

0 comments on commit 63627d7

Please sign in to comment.