Skip to content

Commit 19e36bb

Browse files
committed
Add fs.cpp/h
1 parent a2cd0b0 commit 19e36bb

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

src/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ BITCOIN_CORE_H = \
9898
core_io.h \
9999
core_memusage.h \
100100
cuckoocache.h \
101+
fs.h \
101102
httprpc.h \
102103
httpserver.h \
103104
indirectmap.h \
@@ -326,6 +327,7 @@ libbitcoin_util_a_SOURCES = \
326327
compat/glibc_sanity.cpp \
327328
compat/glibcxx_sanity.cpp \
328329
compat/strnlen.cpp \
330+
fs.cpp \
329331
random.cpp \
330332
rpc/protocol.cpp \
331333
support/cleanse.cpp \

src/fs.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "fs.h"
2+
3+
#include <boost/filesystem.hpp>
4+
5+
namespace fsbridge {
6+
7+
FILE *fopen(const fs::path& p, const char *mode)
8+
{
9+
return ::fopen(p.string().c_str(), mode);
10+
}
11+
12+
FILE *freopen(const fs::path& p, const char *mode, FILE *stream)
13+
{
14+
return ::freopen(p.string().c_str(), mode, stream);
15+
}
16+
17+
} // fsbridge

src/fs.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) 2017 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef BITCOIN_FS_H
6+
#define BITCOIN_FS_H
7+
8+
#include <stdio.h>
9+
#include <string>
10+
11+
#include <boost/filesystem.hpp>
12+
#include <boost/filesystem/fstream.hpp>
13+
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
14+
15+
/** Filesystem operations and types */
16+
namespace fs = boost::filesystem;
17+
18+
/** Bridge operations to C stdio */
19+
namespace fsbridge {
20+
FILE *fopen(const fs::path& p, const char *mode);
21+
FILE *freopen(const fs::path& p, const char *mode, FILE *stream);
22+
};
23+
24+
#endif

0 commit comments

Comments
 (0)