• R/O
  • SSH
  • HTTPS

hamigaki: 提交


Commit MetaInfo

修訂1539 (tree)
時間2008-04-05 14:52:40
作者hamigaki

Log Message

added create_hard_link()

Change Summary

差異

--- sandbox/trunk/libs/filesystem2/src/windows/narrow_functions.hpp (revision 1538)
+++ sandbox/trunk/libs/filesystem2/src/windows/narrow_functions.hpp (revision 1539)
@@ -51,6 +51,13 @@
5151 return ::SetFileAttributesA(ph, dwFileAttributes);
5252 }
5353
54+#if (_WIN32_WINNT >= 0x500)
55+inline BOOL create_hard_link(const char* from_ph, const char* to_ph)
56+{
57+ return ::CreateHardLinkA(from_ph, to_ph, 0);
58+}
59+#endif
60+
5461 } } } // End namespaces detail, filesystem, hamigaki.
5562
5663 #endif // HAMIGAKI_FILESYSTEM_WINDOWS_NARROW_FUNCTIONS_HPP
--- sandbox/trunk/libs/filesystem2/src/windows/wide_functions.hpp (revision 1538)
+++ sandbox/trunk/libs/filesystem2/src/windows/wide_functions.hpp (revision 1539)
@@ -52,6 +52,13 @@
5252 return ::SetFileAttributesW(ph, dwFileAttributes);
5353 }
5454
55+#if (_WIN32_WINNT >= 0x500)
56+inline BOOL create_hard_link(const wchar_t* from_ph, const wchar_t* to_ph)
57+{
58+ return ::CreateHardLinkW(from_ph, to_ph, 0);
59+}
60+#endif
61+
5562 } } } // End namespaces detail, filesystem, hamigaki.
5663
5764 #endif // HAMIGAKI_FILESYSTEM_WINDOWS_WIDE_FUNCTIONS_HPP
--- sandbox/trunk/libs/filesystem2/src/windows/helpers.hpp (revision 1538)
+++ sandbox/trunk/libs/filesystem2/src/windows/helpers.hpp (revision 1539)
@@ -302,6 +302,20 @@
302302
303303 template<class String>
304304 inline error_code
305+create_hard_link_template(const String& to_ph, const String& from_ph)
306+{
307+#if (_WIN32_WINNT >= 0x500)
308+ if (detail::create_hard_link(from_ph.c_str(), to_ph.c_str()))
309+ return error_code();
310+ else
311+ return last_error();
312+#else
313+ return make_error_code(ERROR_NOT_SUPPORTED);
314+#endif
315+}
316+
317+template<class String>
318+inline error_code
305319 create_file_symlink_template(const String& to_ph, const String& from_ph)
306320 {
307321 #if defined(HAMIGAKI_FILESYSTEM_USE_REPARSE_POINT)
--- sandbox/trunk/hamigaki/filesystem2/operations.hpp (revision 1538)
+++ sandbox/trunk/hamigaki/filesystem2/operations.hpp (revision 1539)
@@ -66,6 +66,9 @@
6666
6767
6868 HAMIGAKI_FILESYSTEM_DECL error_code
69+create_hard_link_api(const std::wstring& to_ph, const std::wstring& from_ph);
70+
71+HAMIGAKI_FILESYSTEM_DECL error_code
6972 create_file_symlink_api(const std::wstring& to_ph, const std::wstring& from_ph);
7073
7174 HAMIGAKI_FILESYSTEM_DECL error_code
@@ -118,6 +121,9 @@
118121
119122
120123 HAMIGAKI_FILESYSTEM_DECL error_code
124+create_hard_link_api(const std::string& to_ph, const std::string& from_ph);
125+
126+HAMIGAKI_FILESYSTEM_DECL error_code
121127 create_file_symlink_api(const std::string& to_ph, const std::string& from_ph);
122128
123129 HAMIGAKI_FILESYSTEM_DECL error_code
@@ -238,6 +244,26 @@
238244
239245
240246 HAMIGAKI_FS_FUNC(void)
247+create_hard_link(const Path& to_ph, const Path& from_ph)
248+{
249+ const error_code& ec = detail::create_hard_link_api(
250+ to_ph.external_file_string(), from_ph.external_file_string());
251+ if (ec)
252+ {
253+ throw boost::filesystem::basic_filesystem_error<Path>(
254+ "hamigaki::filesystem::create_hard_link", to_ph, from_ph, ec);
255+ }
256+}
257+
258+HAMIGAKI_FS_FUNC(error_code)
259+create_hard_link(const Path& to_ph, const Path& from_ph, error_code& ec)
260+{
261+ ec = detail::create_hard_link_api(
262+ to_ph.external_file_string(), from_ph.external_file_string());
263+ return ec;
264+}
265+
266+HAMIGAKI_FS_FUNC(void)
241267 create_file_symlink(const Path& to_ph, const Path& from_ph)
242268 {
243269 const error_code& ec = detail::create_file_symlink_api(
@@ -245,8 +271,7 @@
245271 if (ec)
246272 {
247273 throw boost::filesystem::basic_filesystem_error<Path>(
248- "hamigaki::filesystem::create_file_symlink",
249- to_ph, from_ph, ec);
274+ "hamigaki::filesystem::create_file_symlink", to_ph, from_ph, ec);
250275 }
251276 }
252277
@@ -475,6 +500,26 @@
475500 }
476501
477502
503+inline void create_hard_link(const path& to_ph, const path& from_ph)
504+{
505+ hamigaki::filesystem::create_hard_link<path>(to_ph, from_ph);
506+}
507+inline void create_hard_link(const wpath& to_ph, const wpath& from_ph)
508+{
509+ hamigaki::filesystem::create_hard_link<wpath>(to_ph, from_ph);
510+}
511+
512+inline error_code
513+create_hard_link(const path& to_ph, const path& from_ph, error_code& ec)
514+{
515+ return hamigaki::filesystem::create_hard_link<path>(to_ph, from_ph, ec);
516+}
517+inline error_code
518+create_hard_link(const wpath& to_ph, const wpath& from_ph, error_code& ec)
519+{
520+ return hamigaki::filesystem::create_hard_link<wpath>(to_ph, from_ph, ec);
521+}
522+
478523 inline void create_file_symlink(const path& to_ph, const path& from_ph)
479524 {
480525 hamigaki::filesystem::create_file_symlink<path>(to_ph, from_ph);
Show on old repository browser