Skip to content

Commit 83e6ec1

Browse files
committed
add filesystem examples
1 parent 7f70b37 commit 83e6ec1

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

Makefile.mos

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ install: boost
3535
cp README.md ${PREFIX}/
3636
cp README_MORPHOS.md ${PREFIX}/
3737
cp LICENSE_1_0.txt ${PREFIX}/
38+
cp -r examples_mos ${PREFIX}/
3839

3940

4041
package: install

examples_mos/Makefile.mos

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
CC=/gg/bin/ppc-morphos-gcc-11
2+
CXX=/gg/bin/ppc-morphos-g++-11
3+
4+
C_FLAGS=-Ofast -noixemul -mcpu=G4 -maltivec -mabi=altivec -DNDEBUG -D__MORPHOS__
5+
CXX_FLAGS=-std=c++17
6+
7+
LD_FLAGS=-L/tmp/boost-1.87.0-morphos-ppc/lib -lboost_filesystem
8+
INCLUDES=-I/tmp/boost-1.87.0-morphos-ppc/include
9+
10+
all: example-filesystem-cpp17 example-filesystem-boost
11+
12+
#--- build example-filesystem-boost: ---#
13+
example-filesystem-boost: example-filesystem-boost.cpp
14+
$(CXX) -o ${@} $(^) ${C_FLAGS} ${CXX_FLAGS} ${INCLUDES} ${LD_FLAGS}
15+
16+
#--- build example-filesystem-cpp17: ---#
17+
example-filesystem-cpp17: example-filesystem-cpp17.cpp
18+
$(CXX) -o ${@} $(^) ${C_FLAGS} ${CXX_FLAGS}
19+
20+
#--- clean ---#
21+
.PHONY: clean
22+
clean:
23+
rm -f example-filesystem-boost
24+
rm -f example-filesystem-cpp17
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <iostream>
2+
#include <boost/filesystem.hpp>
3+
4+
int main(int argc, char *argv[]) {
5+
if (argc < 2) {
6+
std::cout << "Usage: " << argv[0] << " <path> " << std::endl;
7+
return 1;
8+
}
9+
const boost::filesystem::path p{argv[1]};
10+
if (boost::filesystem::exists(p)) {
11+
std::cout << p.string() << " size: " << boost::filesystem::file_size(p) << " kb" << std::endl;
12+
} else {
13+
std::cout << p.string() << " does not exists!" << boost::filesystem::file_size(p) << std::endl;
14+
}
15+
16+
return 0;
17+
}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <iostream>
2+
#include <filesystem>
3+
4+
int main(int argc, char *argv[]) {
5+
if (argc < 2) {
6+
std::cout << "Usage: " << argv[0] << " <path> " << std::endl;
7+
return 1;
8+
}
9+
const std::filesystem::path p{argv[1]};
10+
if (std::filesystem::exists(p)) {
11+
std::cout << p.string() << " size: " << std::filesystem::file_size(p) << " kb" << std::endl;
12+
} else {
13+
std::cout << p.string() << " does not exists!" << std::filesystem::file_size(p) << std::endl;
14+
}
15+
16+
return 0;
17+
}

0 commit comments

Comments
 (0)