mirror of
https://github.com/boostorg/filesystem.git
synced 2026-02-27 17:02:19 +00:00
Move files into new v2 + v3 directory structure
[SVN r62653]
This commit is contained in:
1368
src/operations.cpp
1368
src/operations.cpp
File diff suppressed because it is too large
Load Diff
173
src/path.cpp
173
src/path.cpp
@@ -1,173 +0,0 @@
|
||||
// path.cpp ----------------------------------------------------------------//
|
||||
|
||||
// Copyright 2005 Beman Dawes
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See library home page at http://www.boost.org/libs/filesystem
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
|
||||
// the library is being built (possibly exporting rather than importing code)
|
||||
#define BOOST_FILESYSTEM_SOURCE
|
||||
|
||||
#include <boost/filesystem/config.hpp>
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/scoped_array.hpp>
|
||||
|
||||
#include <locale>
|
||||
#include <boost/cerrno.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
|
||||
#include <cwchar> // for std::mbstate_t
|
||||
|
||||
#if defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
|
||||
# include "utf8_codecvt_facet.hpp"
|
||||
#endif
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
// std::locale construction can throw (if LC_MESSAGES is wrong, for example),
|
||||
// so a static at function scope is used to ensure that exceptions can be
|
||||
// caught. (A previous version was at namespace scope, so initialization
|
||||
// occurred before main(), preventing exceptions from being caught.)
|
||||
std::locale & loc()
|
||||
{
|
||||
#if !defined(macintosh) && !defined(__APPLE__) && !defined(__APPLE_CC__)
|
||||
// ISO C calls this "the locale-specific native environment":
|
||||
static std::locale lc("");
|
||||
#else // Mac OS
|
||||
// "All BSD system functions expect their string parameters to be in UTF-8 encoding
|
||||
// and nothing else."
|
||||
// See http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPInternational/Articles/FileEncodings.html
|
||||
std::locale global_loc = std::locale(); // Mac OS doesn't support locale("")
|
||||
static std::locale lc(global_loc,
|
||||
new boost::filesystem::detail::utf8_codecvt_facet);
|
||||
#endif
|
||||
return lc;
|
||||
}
|
||||
|
||||
const std::codecvt<wchar_t, char, std::mbstate_t> *&
|
||||
converter()
|
||||
{
|
||||
static const std::codecvt<wchar_t, char, std::mbstate_t> *
|
||||
cvtr(
|
||||
&std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >
|
||||
( loc() ) );
|
||||
return cvtr;
|
||||
}
|
||||
|
||||
bool locked(false);
|
||||
} // unnamed namespace
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
bool wpath_traits::imbue( const std::locale & new_loc, const std::nothrow_t & )
|
||||
{
|
||||
if ( locked ) return false;
|
||||
locked = true;
|
||||
loc() = new_loc;
|
||||
converter() = &std::use_facet
|
||||
<std::codecvt<wchar_t, char, std::mbstate_t> >( loc() );
|
||||
return true;
|
||||
}
|
||||
|
||||
void wpath_traits::imbue( const std::locale & new_loc )
|
||||
{
|
||||
if ( locked ) boost::throw_exception(
|
||||
wfilesystem_error(
|
||||
"boost::filesystem::wpath_traits::imbue() after lockdown",
|
||||
make_error_code( system::posix::not_supported ) ) );
|
||||
imbue( new_loc, std::nothrow );
|
||||
}
|
||||
|
||||
//namespace detail
|
||||
//{
|
||||
// BOOST_FILESYSTEM_DECL
|
||||
// const char * what( const char * sys_err_what,
|
||||
// const path & path1, const path & path2, std::string & target)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if ( target.empty() )
|
||||
// {
|
||||
// target = sys_err_what;
|
||||
// if ( !path1.empty() )
|
||||
// {
|
||||
// target += ": \"";
|
||||
// target += path1.file_string();
|
||||
// target += "\"";
|
||||
// }
|
||||
// if ( !path2.empty() )
|
||||
// {
|
||||
// target += ", \"";
|
||||
// target += path2.file_string();
|
||||
// target += "\"";
|
||||
// }
|
||||
// }
|
||||
// return target.c_str();
|
||||
// }
|
||||
// catch (...)
|
||||
// {
|
||||
// return sys_err_what;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
# ifdef BOOST_POSIX_API
|
||||
|
||||
// Because this is POSIX only code, we don't have to worry about ABI issues
|
||||
// described in http://www.boost.org/more/separate_compilation.html
|
||||
|
||||
wpath_traits::external_string_type
|
||||
wpath_traits::to_external( const wpath & ph,
|
||||
const internal_string_type & src )
|
||||
{
|
||||
locked = true;
|
||||
std::size_t work_size( converter()->max_length() * (src.size()+1) );
|
||||
boost::scoped_array<char> work( new char[ work_size ] );
|
||||
std::mbstate_t state = std::mbstate_t(); // perhaps unneeded, but cuts bug reports
|
||||
const internal_string_type::value_type * from_next;
|
||||
external_string_type::value_type * to_next;
|
||||
if ( converter()->out(
|
||||
state, src.c_str(), src.c_str()+src.size(), from_next, work.get(),
|
||||
work.get()+work_size, to_next ) != std::codecvt_base::ok )
|
||||
boost::throw_exception( boost::filesystem::wfilesystem_error(
|
||||
"boost::filesystem::wpath::to_external conversion error",
|
||||
ph, system::error_code( system::posix::invalid_argument, system::system_category() ) ) );
|
||||
*to_next = '\0';
|
||||
return external_string_type( work.get() );
|
||||
}
|
||||
|
||||
wpath_traits::internal_string_type
|
||||
wpath_traits::to_internal( const external_string_type & src )
|
||||
{
|
||||
locked = true;
|
||||
std::size_t work_size( src.size()+1 );
|
||||
boost::scoped_array<wchar_t> work( new wchar_t[ work_size ] );
|
||||
std::mbstate_t state = std::mbstate_t(); // perhaps unneeded, but cuts bug reports
|
||||
const external_string_type::value_type * from_next;
|
||||
internal_string_type::value_type * to_next;
|
||||
if ( converter()->in(
|
||||
state, src.c_str(), src.c_str()+src.size(), from_next, work.get(),
|
||||
work.get()+work_size, to_next ) != std::codecvt_base::ok )
|
||||
boost::throw_exception( boost::filesystem::wfilesystem_error(
|
||||
"boost::filesystem::wpath::to_internal conversion error",
|
||||
system::error_code( system::posix::invalid_argument, system::system_category() ) ) );
|
||||
*to_next = L'\0';
|
||||
return internal_string_type( work.get() );
|
||||
}
|
||||
# endif // BOOST_POSIX_API
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
|
||||
#endif // ifndef BOOST_FILESYSTEM_NARROW_ONLY
|
||||
@@ -1,115 +0,0 @@
|
||||
// portability.cpp ---------------------------------------------------------//
|
||||
|
||||
// Copyright 2002-2005 Beman Dawes
|
||||
// Use, modification, and distribution is subject to the Boost Software
|
||||
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
|
||||
// at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See library home page at http://www.boost.org/libs/filesystem
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
// define BOOST_FILESYSTEM_SOURCE so that <boost/filesystem/config.hpp> knows
|
||||
// the library is being built (possibly exporting rather than importing code)
|
||||
#define BOOST_FILESYSTEM_SOURCE
|
||||
|
||||
#include <boost/filesystem/config.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
#include <cstring> // SGI MIPSpro compilers need this
|
||||
|
||||
# ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std { using ::strerror; }
|
||||
# endif
|
||||
|
||||
//----------------------------------------------------------------------------//
|
||||
|
||||
namespace
|
||||
{
|
||||
const char invalid_chars[] =
|
||||
"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F"
|
||||
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"
|
||||
"<>:\"/\\|";
|
||||
// note that the terminating '\0' is part of the string - thus the size below
|
||||
// is sizeof(invalid_chars) rather than sizeof(invalid_chars)-1. I
|
||||
const std::string windows_invalid_chars( invalid_chars, sizeof(invalid_chars) );
|
||||
|
||||
const std::string valid_posix(
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-" );
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
|
||||
// name_check functions ----------------------------------------------//
|
||||
|
||||
# ifdef BOOST_WINDOWS
|
||||
BOOST_FILESYSTEM_DECL bool native( const std::string & name )
|
||||
{
|
||||
return windows_name( name );
|
||||
}
|
||||
# else
|
||||
BOOST_FILESYSTEM_DECL bool native( const std::string & name )
|
||||
{
|
||||
return name.size() != 0
|
||||
&& name[0] != ' '
|
||||
&& name.find('/') == std::string::npos;
|
||||
}
|
||||
# endif
|
||||
|
||||
BOOST_FILESYSTEM_DECL bool portable_posix_name( const std::string & name )
|
||||
{
|
||||
return name.size() != 0
|
||||
&& name.find_first_not_of( valid_posix ) == std::string::npos;
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL bool windows_name( const std::string & name )
|
||||
{
|
||||
return name.size() != 0
|
||||
&& name[0] != ' '
|
||||
&& name.find_first_of( windows_invalid_chars ) == std::string::npos
|
||||
&& *(name.end()-1) != ' '
|
||||
&& (*(name.end()-1) != '.'
|
||||
|| name.length() == 1 || name == "..");
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL bool portable_name( const std::string & name )
|
||||
{
|
||||
return
|
||||
name.size() != 0
|
||||
&& ( name == "."
|
||||
|| name == ".."
|
||||
|| (windows_name( name )
|
||||
&& portable_posix_name( name )
|
||||
&& name[0] != '.' && name[0] != '-'));
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL bool portable_directory_name( const std::string & name )
|
||||
{
|
||||
return
|
||||
name == "."
|
||||
|| name == ".."
|
||||
|| (portable_name( name )
|
||||
&& name.find('.') == std::string::npos);
|
||||
}
|
||||
|
||||
BOOST_FILESYSTEM_DECL bool portable_file_name( const std::string & name )
|
||||
{
|
||||
std::string::size_type pos;
|
||||
return
|
||||
portable_name( name )
|
||||
&& name != "."
|
||||
&& name != ".."
|
||||
&& ( (pos = name.find( '.' )) == std::string::npos
|
||||
|| (name.find( '.', pos+1 ) == std::string::npos
|
||||
&& (pos + 5) > name.length() ))
|
||||
;
|
||||
}
|
||||
|
||||
} // namespace filesystem
|
||||
} // namespace boost
|
||||
@@ -1,20 +0,0 @@
|
||||
// Copyright Vladimir Prus 2004.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#define BOOST_FILESYSTEM_SOURCE
|
||||
#include <boost/filesystem/config.hpp>
|
||||
|
||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||
namespace boost { namespace filesystem { namespace detail {
|
||||
|
||||
#define BOOST_UTF8_END_NAMESPACE }}}
|
||||
#define BOOST_UTF8_DECL BOOST_FILESYSTEM_DECL
|
||||
|
||||
#include "libs/detail/utf8_codecvt_facet.cpp"
|
||||
|
||||
|
||||
#undef BOOST_UTF8_BEGIN_NAMESPACE
|
||||
#undef BOOST_UTF8_END_NAMESPACE
|
||||
#undef BOOST_UTF8_DECL
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright (c) 2001 Ronald Garcia, Indiana University (garcia@osl.iu.edu)
|
||||
// Andrew Lumsdaine, Indiana University (lums@osl.iu.edu).
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_FILESYSTEM_UTF8_CODECVT_FACET_HPP
|
||||
#define BOOST_FILESYSTEM_UTF8_CODECVT_FACET_HPP
|
||||
|
||||
#include <boost/filesystem/config.hpp>
|
||||
|
||||
#define BOOST_UTF8_BEGIN_NAMESPACE \
|
||||
namespace boost { namespace filesystem { namespace detail {
|
||||
|
||||
#define BOOST_UTF8_END_NAMESPACE }}}
|
||||
#define BOOST_UTF8_DECL BOOST_FILESYSTEM_DECL
|
||||
|
||||
#include <boost/detail/utf8_codecvt_facet.hpp>
|
||||
|
||||
#undef BOOST_UTF8_BEGIN_NAMESPACE
|
||||
#undef BOOST_UTF8_END_NAMESPACE
|
||||
#undef BOOST_UTF8_DECL
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user