}
if (is_other(f) || is_other(t))
{
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::invalid_argument);
return;
}
if (is_directory(f) && is_regular_file(t))
else
ec.clear();
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
}
return do_copy_file(from.c_str(), to.c_str(), copy_file_options(options),
nullptr, nullptr, ec);
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
return false;
#endif
}
created = true;
}
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
return created;
}
}
return create_dir(p, static_cast<perms>(st.st_mode), ec);
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_function_not_supported);
return false;
#endif
}
error_code& ec) noexcept
{
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#else
create_symlink(to, new_symlink, ec);
#endif
else
ec = __last_system_error();
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
}
else
ec.clear();
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
}
}
#endif // __GLIBC__
#else // _GLIBCXX_HAVE_UNISTD_H
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
return p;
}
else
ec.clear();
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
}
{
if (is_other(s1) && is_other(s2))
{
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::__unsupported();
return false;
}
ec.clear();
ec.clear();
return false;
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
return false;
}
ec.clear();
return f(st);
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
return deflt;
#endif
}
if (s.type == file_type::directory)
ec = std::make_error_code(std::errc::is_a_directory);
else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::__unsupported();
}
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
return -1;
}
return do_stat(p, ec, std::mem_fn(&stat_type::st_nlink),
static_cast<uintmax_t>(-1));
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
return static_cast<uintmax_t>(-1);
#endif
}
},
file_time_type::min());
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
return file_time_type::min();
#endif
}
else
ec.clear();
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
}
err = errno;
#else
if (nofollow && is_symlink(st))
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::__unsupported();
else if (posix::chmod(p.c_str(), static_cast<posix::mode_t>(prms)))
err = errno;
#endif
}
while (true);
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
return result;
}
void
fs::resize_file(const path& p, uintmax_t size, error_code& ec) noexcept
{
- if (size > static_cast<uintmax_t>(std::numeric_limits<off_t>::max()))
+ if (size > static_cast<uintmax_t>(std::numeric_limits<posix::off_t>::max()))
ec.assign(EINVAL, std::generic_category());
else if (posix::truncate(p.c_str(), size))
ec.assign(errno, std::generic_category());
#endif
}
+ // Get an error code indicating unsupported functionality.
+ //
+ // This should be used when a function is unable to behave as specified
+ // due to an incomplete or partial implementation, e.g.
+ // filesystem::equivalent(a, b) if is_other(a) && is_other(b) is true.
+ //
+ // Use errc::function_not_supported for functions that are entirely
+ // unimplemented, e.g. create_symlink on Windows.
+ //
+ // Use errc::invalid_argument for requests to perform operations outside
+ // the spec, e.g. trying to copy a directory using filesystem::copy_file.
+ inline error_code
+ __unsupported() noexcept
+ {
+#if defined ENOTSUP
+ return std::make_error_code(std::errc::not_supported);
+#elif defined EOPNOTSUPP
+ // This is supposed to be for socket operations
+ return std::make_error_code(std::errc::operation_not_supported);
+#else
+ return std::make_error_code(std::errc::invalid_argument);
+#endif
+ }
+
namespace filesystem
{
namespace __gnu_posix
return -1;
}
+ using off_t = _off64_t;
inline int truncate(const wchar_t* path, _off64_t length)
{
const int fd = ::_wopen(path, _O_BINARY|_O_RDWR);
using ::utime;
# endif
using ::rename;
+ using ::off_t;
# ifdef _GLIBCXX_HAVE_TRUNCATE
using ::truncate;
# else
# endif
using char_type = char;
#else // ! _GLIBCXX_FILESYSTEM_IS_WINDOWS && ! _GLIBCXX_HAVE_UNISTD_H
- inline int open(const char*, int, ...) { errno = ENOTSUP; return -1; }
- inline int close(int) { errno = ENOTSUP; return -1; }
+ inline int open(const char*, int, ...) { errno = ENOSYS; return -1; }
+ inline int close(int) { errno = ENOSYS; return -1; }
using mode_t = int;
- inline int chmod(const char*, mode_t) { errno = ENOTSUP; return -1; }
- inline int mkdir(const char*, mode_t) { errno = ENOTSUP; return -1; }
- inline char* getcwd(char*, size_t) { errno = ENOTSUP; return nullptr; }
- inline int chdir(const char*) { errno = ENOTSUP; return -1; }
- inline int rename(const char*, const char*) { errno = ENOTSUP; return -1; }
- inline int truncate(const char*, long) { errno = ENOTSUP; return -1; }
+ inline int chmod(const char*, mode_t) { errno = ENOSYS; return -1; }
+ inline int mkdir(const char*, mode_t) { errno = ENOSYS; return -1; }
+ inline char* getcwd(char*, size_t) { errno = ENOSYS; return nullptr; }
+ inline int chdir(const char*) { errno = ENOSYS; return -1; }
+ inline int rename(const char*, const char*) { errno = ENOSYS; return -1; }
+ using off_t = long;
+ inline int truncate(const char*, off_t) { errno = ENOSYS; return -1; }
using char_type = char;
#endif // _GLIBCXX_FILESYSTEM_IS_WINDOWS
} // namespace __gnu_posix
// 2712. copy_file() has a number of unspecified error conditions
if (!is_regular_file(f))
{
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::invalid_argument);
return false;
}
{
if (!is_regular_file(t))
{
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::invalid_argument);
return false;
}
}
else if (!is_regular_file(t))
{
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::invalid_argument);
return false;
}
}
else
ec = std::last_system_error();
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
}
#pragma GCC diagnostic pop
}
if (is_other(f) || is_other(t))
{
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::invalid_argument);
return;
}
if (is_directory(f) && is_regular_file(t))
return do_copy_file(from.c_str(), to.c_str(), copy_file_options(options),
nullptr, nullptr, ec);
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
return false;
#endif
}
created = true;
}
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
return created;
}
}
return create_dir(p, static_cast<perms>(st.st_mode), ec);
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
return false;
#endif
}
error_code& ec) noexcept
{
#ifdef _GLIBCXX_FILESYSTEM_IS_WINDOWS
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#else
create_symlink(to, new_symlink, ec);
#endif
else
ec = __last_system_error();
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
}
else
ec.clear();
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
}
}
#endif // __GLIBC__
#else // _GLIBCXX_HAVE_UNISTD_H
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
return p;
}
else
ec.clear();
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
}
{
if (is_other(s1) && is_other(s2))
{
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::__unsupported();
return false;
}
ec.clear();
ec.clear();
return false;
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
return false;
}
ec.clear();
return f(st);
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
return deflt;
#endif
}
if (s.type == file_type::directory)
ec = std::make_error_code(std::errc::is_a_directory);
else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::__unsupported();
}
return -1;
}
else
ec.clear();
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
}
err = errno;
#else
if (nofollow && is_symlink(st))
- ec = std::make_error_code(std::errc::operation_not_supported);
+ ec = std::__unsupported();
else if (posix::chmod(p.c_str(), static_cast<mode_t>(prms)))
err = errno;
#endif
}
while (true);
#else
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::make_error_code(std::errc::function_not_supported);
#endif
return result;
}
void
fs::resize_file(const path& p, uintmax_t size, error_code& ec) noexcept
{
-#ifdef _GLIBCXX_HAVE_UNISTD_H
- if (size > static_cast<uintmax_t>(std::numeric_limits<off_t>::max()))
+ if (size > static_cast<uintmax_t>(std::numeric_limits<posix::off_t>::max()))
ec.assign(EINVAL, std::generic_category());
else if (posix::truncate(p.c_str(), size))
ec.assign(errno, std::generic_category());
else
ec.clear();
-#else
- ec = std::make_error_code(std::errc::not_supported);
-#endif
}
|| p.root_name() == base.root_name())
return absolute(p, base);
// else TODO
- ec = std::make_error_code(std::errc::not_supported);
+ ec = std::__unsupported();
return {};
#else
if (ec.value())
{
const std::string s("too late: boulangerie out of pain au raisin");
const std::error_code
- e(std::make_error_code(std::errc::operation_not_supported));
+ e(std::make_error_code(std::errc::invalid_argument));
// 1
{
std::system_error err1(e, s);
- VERIFY( err1.code() == e );
+ VERIFY( err1.code() == e );
VERIFY( std::string(err1.what()).find(s) != std::string::npos );
}
// 2
{
std::system_error err2(95, std::system_category(), s);
- VERIFY( err2.code() == std::error_code(95, std::system_category()) );
+ VERIFY( err2.code() == std::error_code(95, std::system_category()) );
VERIFY( std::string((err2.what(), s)).find(s) != std::string::npos );
}