You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

955 lines
37 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/shell/file_operations.hpp
  3. *
  4. * Purpose: Shell file operations.
  5. *
  6. * Created: 12th December 1996
  7. * Updated: 15th February 2010
  8. *
  9. * Thanks: To Pablo Aguilar for default folder enhancements.
  10. *
  11. * Home: http://stlsoft.org/
  12. *
  13. * Copyright (c) 1996-2010, Matthew Wilson and Synesis Software
  14. * Copyright (c) 2005, Pablo Aguilar
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without
  18. * modification, are permitted provided that the following conditions are met:
  19. *
  20. * - Redistributions of source code must retain the above copyright notice, this
  21. * list of conditions and the following disclaimer.
  22. * - Redistributions in binary form must reproduce the above copyright notice,
  23. * this list of conditions and the following disclaimer in the documentation
  24. * and/or other materials provided with the distribution.
  25. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  26. * any contributors may be used to endorse or promote products derived from
  27. * this software without specific prior written permission.
  28. *
  29. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  30. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  32. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  33. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  34. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  35. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  36. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  37. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  38. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  39. * POSSIBILITY OF SUCH DAMAGE.
  40. *
  41. * ////////////////////////////////////////////////////////////////////// */
  42. /** \file winstl/shell/file_operations.hpp
  43. *
  44. * \brief [C++ only] Definition of Windows Shell file operation functions
  45. * (\ref group__library__windows_shell "Windows Shell" Library).
  46. */
  47. #ifndef WINSTL_INCL_WINSTL_SHELL_HPP_FILE_OPERATIONS
  48. #define WINSTL_INCL_WINSTL_SHELL_HPP_FILE_OPERATIONS
  49. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  50. # define WINSTL_VER_WINSTL_SHELL_HPP_FILE_OPERATIONS_MAJOR 2
  51. # define WINSTL_VER_WINSTL_SHELL_HPP_FILE_OPERATIONS_MINOR 1
  52. # define WINSTL_VER_WINSTL_SHELL_HPP_FILE_OPERATIONS_REVISION 3
  53. # define WINSTL_VER_WINSTL_SHELL_HPP_FILE_OPERATIONS_EDIT 89
  54. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  55. /* /////////////////////////////////////////////////////////////////////////
  56. * Includes.
  57. */
  58. #ifndef WINSTL_INCL_WINSTL_H_WINSTL
  59. # include <winstl/winstl.h>
  60. #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
  61. #ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_SHELL_ALLOCATOR
  62. # include <winstl/memory/shell_allocator.hpp>
  63. #endif /* !WINSTL_INCL_WINSTL_MEMORY_HPP_SHELL_ALLOCATOR */
  64. #ifndef STLSOFT_INCL_STLSOFT_MEMORY_HPP_AUTO_BUFFER
  65. # include <stlsoft/memory/auto_buffer.hpp>
  66. #endif /* !STLSOFT_INCL_STLSOFT_MEMORY_HPP_AUTO_BUFFER */
  67. //#ifndef STLSOFT_INCL_STLSOFT_HPP_STRING_ACCESS
  68. //# include <stlsoft/string_access.hpp>
  69. //#endif /* !STLSOFT_INCL_STLSOFT_HPP_STRING_ACCESS */
  70. //#ifndef WINSTL_INCL_WINSTL_SHIMS_ACCESS_HPP_STRING
  71. //# include <winstl/shims/access/string.hpp>
  72. //#endif /* !WINSTL_INCL_WINSTL_SHIMS_ACCESS_HPP_STRING */
  73. #ifndef STLSOFT_INCL_STLSOFT_HPP_AUTO_BUFFER
  74. # include <winstl/winstl.h>
  75. #endif /* !STLSOFT_INCL_STLSOFT_HPP_AUTO_BUFFER */
  76. /* /////////////////////////////////////////////////////////////////////////
  77. * Namespace
  78. */
  79. #ifndef _WINSTL_NO_NAMESPACE
  80. # if defined(_STLSOFT_NO_NAMESPACE) || \
  81. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  82. /* There is no stlsoft namespace, so must define ::winstl */
  83. namespace winstl
  84. {
  85. # else
  86. /* Define stlsoft::winstl_project */
  87. namespace stlsoft
  88. {
  89. namespace winstl_project
  90. {
  91. # endif /* _STLSOFT_NO_NAMESPACE */
  92. #endif /* !_WINSTL_NO_NAMESPACE */
  93. /* /////////////////////////////////////////////////////////////////////////
  94. * Functions
  95. */
  96. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  97. inline int shell_delete_a_(HWND hwnd, ws_char_a_t const* from, ws_char_a_t const* progressTitle, FILEOP_FLAGS flags, ws_bool_t *pbAborted)
  98. {
  99. WINSTL_MESSAGE_ASSERT("Null string cannot be specified", NULL != from);
  100. typedef auto_buffer<ws_char_a_t, 2 + WINSTL_CONST_MAX_PATH, shell_allocator<ws_char_a_t> > buffer_t;
  101. ws_size_t cch = static_cast<ws_size_t>(::lstrlenA(from));
  102. buffer_t buff(1 + cch + 1);
  103. if(buff.empty())
  104. {
  105. ::SetLastError(ERROR_NOT_ENOUGH_MEMORY);
  106. return ERROR_NOT_ENOUGH_MEMORY;
  107. }
  108. else
  109. {
  110. SHFILEOPSTRUCTA sos;
  111. ::lstrcpyA(&buff[0], from);
  112. buff[cch + 1] = '\0';
  113. flags &= ~(FOF_WANTMAPPINGHANDLE);
  114. flags |= static_cast<FILEOP_FLAGS>((NULL == progressTitle) ? 0 : FOF_SIMPLEPROGRESS);
  115. sos.hwnd = hwnd;
  116. sos.wFunc = FO_DELETE;
  117. sos.pFrom = buff.data();
  118. sos.pTo = NULL;
  119. sos.fFlags = flags;
  120. sos.fAnyOperationsAborted = false;
  121. sos.hNameMappings = NULL;
  122. sos.lpszProgressTitle = progressTitle;
  123. int res = ::SHFileOperationA(&sos);
  124. if(0 == res)
  125. {
  126. if(NULL != pbAborted)
  127. {
  128. *pbAborted = (FALSE != sos.fAnyOperationsAborted);
  129. }
  130. }
  131. return res;
  132. }
  133. }
  134. inline int shell_delete_w_(HWND hwnd, ws_char_w_t const* from, ws_char_w_t const* progressTitle, FILEOP_FLAGS flags, ws_bool_t *pbAborted)
  135. {
  136. WINSTL_MESSAGE_ASSERT("Null string cannot be specified", NULL != from);
  137. typedef auto_buffer<ws_char_w_t, 2 + WINSTL_CONST_MAX_PATH, shell_allocator<ws_char_w_t> > buffer_t;
  138. ws_size_t cch = static_cast<ws_size_t>(::lstrlenW(from));
  139. buffer_t buff(1 + cch + 1);
  140. if(buff.empty())
  141. {
  142. ::SetLastError(ERROR_NOT_ENOUGH_MEMORY);
  143. return ERROR_NOT_ENOUGH_MEMORY;
  144. }
  145. else
  146. {
  147. SHFILEOPSTRUCTW sos;
  148. ::lstrcpyW(&buff[0], from);
  149. buff[cch + 1] = '\0';
  150. flags &= ~(FOF_WANTMAPPINGHANDLE);
  151. flags |= static_cast<FILEOP_FLAGS>((NULL == progressTitle) ? 0 : FOF_SIMPLEPROGRESS);
  152. sos.hwnd = hwnd;
  153. sos.wFunc = FO_DELETE;
  154. sos.pFrom = buff.data();
  155. sos.pTo = NULL;
  156. sos.fFlags = flags;
  157. sos.fAnyOperationsAborted = false;
  158. sos.hNameMappings = NULL;
  159. sos.lpszProgressTitle = progressTitle;
  160. int res = ::SHFileOperationW(&sos);
  161. if(0 == res)
  162. {
  163. if(NULL != pbAborted)
  164. {
  165. *pbAborted = (FALSE != sos.fAnyOperationsAborted);
  166. }
  167. }
  168. return res;
  169. }
  170. }
  171. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  172. /** \brief Requests the shell to delete the given file
  173. *
  174. * \ingroup group__library__windows_shell
  175. *
  176. * \param from The file to delete
  177. *
  178. * \note Throws std::bad_alloc on allocation failure on translators that support it
  179. *
  180. * \return A status code indicating the success of the operation
  181. *
  182. * \retval 0 The operation completed successfully
  183. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  184. * \retval !0 Any other Win32 error code
  185. */
  186. inline int shell_delete(ws_char_a_t const* from)
  187. {
  188. return shell_delete_a_(NULL, from, NULL, 0, NULL);
  189. }
  190. /** \brief Requests the shell to delete the given file
  191. *
  192. * \ingroup group__library__windows_shell
  193. *
  194. * \param from The file to delete
  195. * \param bAborted A Boolean that will indicate whether the operation was aborted
  196. *
  197. * \note Throws std::bad_alloc on allocation failure on translators that support it
  198. *
  199. * \return A status code indicating the success of the operation
  200. *
  201. * \retval 0 The operation completed successfully
  202. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  203. * \retval !0 Any other Win32 error code
  204. */
  205. inline int shell_delete(ws_char_a_t const* from, ws_bool_t &bAborted)
  206. {
  207. return shell_delete_a_(NULL, from, NULL, 0, &bAborted);
  208. }
  209. /** \brief Requests the shell to delete the given file
  210. *
  211. * \ingroup group__library__windows_shell
  212. *
  213. * \param from The file to delete
  214. * \param flags One or more of the FILEOP_FLAGS values.
  215. *
  216. * \note Throws std::bad_alloc on allocation failure on translators that support it
  217. *
  218. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored.
  219. *
  220. * \return A status code indicating the success of the operation
  221. *
  222. * \retval 0 The operation completed successfully
  223. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  224. * \retval !0 Any other Win32 error code
  225. */
  226. inline int shell_delete(ws_char_a_t const* from, FILEOP_FLAGS flags)
  227. {
  228. return shell_delete_a_(NULL, from, NULL, flags, NULL);
  229. }
  230. /** \brief Requests the shell to delete the given file
  231. *
  232. * \ingroup group__library__windows_shell
  233. *
  234. * \param from The file to delete
  235. * \param flags One or more of the FILEOP_FLAGS values.
  236. * \param bAborted A Boolean that will indicate whether the operation was aborted
  237. *
  238. * \note Throws std::bad_alloc on allocation failure on translators that support it
  239. *
  240. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored
  241. *
  242. * \return A status code indicating the success of the operation
  243. *
  244. * \retval 0 The operation completed successfully
  245. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  246. * \retval !0 Any other Win32 error code
  247. */
  248. inline int shell_delete(ws_char_a_t const* from, FILEOP_FLAGS flags, ws_bool_t &bAborted)
  249. {
  250. return shell_delete_a_(NULL, from, NULL, flags, &bAborted);
  251. }
  252. /** \brief Requests the shell to delete the given file
  253. *
  254. * \ingroup group__library__windows_shell
  255. *
  256. * \param from The file to delete
  257. * \param progressTitle String to be displayed describing the operation
  258. *
  259. * \note Throws std::bad_alloc on allocation failure on translators that support it
  260. *
  261. * \note The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  262. *
  263. * \return A status code indicating the success of the operation
  264. *
  265. * \retval 0 The operation completed successfully
  266. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  267. * \retval !0 Any other Win32 error code
  268. */
  269. inline int shell_delete(ws_char_a_t const* from, ws_char_a_t const* progressTitle)
  270. {
  271. return shell_delete_a_(NULL, from, progressTitle, 0, NULL);
  272. }
  273. /** \brief Requests the shell to delete the given file
  274. *
  275. * \ingroup group__library__windows_shell
  276. *
  277. * \param from The file to delete
  278. * \param progressTitle String to be displayed describing the operation
  279. * \param bAborted A Boolean that will indicate whether the operation was aborted
  280. *
  281. * \note Throws std::bad_alloc on allocation failure on translators that support it
  282. *
  283. * \note The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  284. *
  285. * \return A status code indicating the success of the operation
  286. *
  287. * \retval 0 The operation completed successfully
  288. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  289. * \retval !0 Any other Win32 error code
  290. */
  291. inline int shell_delete(ws_char_a_t const* from, ws_char_a_t const* progressTitle, ws_bool_t &bAborted)
  292. {
  293. return shell_delete_a_(NULL, from, progressTitle, 0, &bAborted);
  294. }
  295. /** \brief Requests the shell to delete the given file
  296. *
  297. * \ingroup group__library__windows_shell
  298. *
  299. * \param from The file to delete
  300. * \param progressTitle String to be displayed describing the operation
  301. * \param flags One or more of the FILEOP_FLAGS values.
  302. *
  303. * \note Throws std::bad_alloc on allocation failure on translators that support it
  304. *
  305. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored. The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  306. *
  307. * \return A status code indicating the success of the operation
  308. *
  309. * \retval 0 The operation completed successfully
  310. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  311. * \retval !0 Any other Win32 error code
  312. */
  313. inline int shell_delete(ws_char_a_t const* from, ws_char_a_t const* progressTitle, FILEOP_FLAGS flags)
  314. {
  315. return shell_delete_a_(NULL, from, progressTitle, flags, NULL);
  316. }
  317. /** \brief Requests the shell to delete the given file
  318. *
  319. * \ingroup group__library__windows_shell
  320. *
  321. * \param from The file to delete
  322. * \param progressTitle String to be displayed describing the operation
  323. * \param flags One or more of the FILEOP_FLAGS values.
  324. * \param bAborted A Boolean that will indicate whether the operation was aborted
  325. *
  326. * \note Throws std::bad_alloc on allocation failure on translators that support it
  327. *
  328. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored. The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  329. *
  330. * \return A status code indicating the success of the operation
  331. *
  332. * \retval 0 The operation completed successfully
  333. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  334. * \retval !0 Any other Win32 error code
  335. */
  336. inline int shell_delete(ws_char_a_t const* from, ws_char_a_t const* progressTitle, FILEOP_FLAGS flags, ws_bool_t &bAborted)
  337. {
  338. return shell_delete_a_(NULL, from, progressTitle, flags, &bAborted);
  339. }
  340. /** \brief Requests the shell to delete the given file
  341. *
  342. * \ingroup group__library__windows_shell
  343. *
  344. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  345. * \param from The file to delete
  346. *
  347. * \note Throws std::bad_alloc on allocation failure on translators that support it
  348. *
  349. * \return A status code indicating the success of the operation
  350. *
  351. * \retval 0 The operation completed successfully
  352. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  353. * \retval !0 Any other Win32 error code
  354. */
  355. inline int shell_delete(HWND hwnd, ws_char_a_t const* from)
  356. {
  357. return shell_delete_a_(hwnd, from, NULL, 0, NULL);
  358. }
  359. /** \brief Requests the shell to delete the given file
  360. *
  361. * \ingroup group__library__windows_shell
  362. *
  363. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  364. * \param from The file to delete
  365. * \param bAborted A Boolean that will indicate whether the operation was aborted
  366. *
  367. * \note Throws std::bad_alloc on allocation failure on translators that support it
  368. *
  369. * \return A status code indicating the success of the operation
  370. *
  371. * \retval 0 The operation completed successfully
  372. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  373. * \retval !0 Any other Win32 error code
  374. */
  375. inline int shell_delete(HWND hwnd, ws_char_a_t const* from, ws_bool_t &bAborted)
  376. {
  377. return shell_delete_a_(hwnd, from, NULL, 0, &bAborted);
  378. }
  379. /** \brief Requests the shell to delete the given file
  380. *
  381. * \ingroup group__library__windows_shell
  382. *
  383. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  384. * \param from The file to delete
  385. * \param flags One or more of the FILEOP_FLAGS values.
  386. *
  387. * \note Throws std::bad_alloc on allocation failure on translators that support it
  388. *
  389. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored.
  390. *
  391. * \return A status code indicating the success of the operation
  392. *
  393. * \retval 0 The operation completed successfully
  394. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  395. * \retval !0 Any other Win32 error code
  396. */
  397. inline int shell_delete(HWND hwnd, ws_char_a_t const* from, FILEOP_FLAGS flags)
  398. {
  399. return shell_delete_a_(hwnd, from, NULL, flags, NULL);
  400. }
  401. /** \brief Requests the shell to delete the given file
  402. *
  403. * \ingroup group__library__windows_shell
  404. *
  405. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  406. * \param from The file to delete
  407. * \param flags One or more of the FILEOP_FLAGS values.
  408. * \param bAborted A Boolean that will indicate whether the operation was aborted
  409. *
  410. * \note Throws std::bad_alloc on allocation failure on translators that support it
  411. *
  412. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored.
  413. *
  414. * \return A status code indicating the success of the operation
  415. *
  416. * \retval 0 The operation completed successfully
  417. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  418. * \retval !0 Any other Win32 error code
  419. */
  420. inline int shell_delete(HWND hwnd, ws_char_a_t const* from, FILEOP_FLAGS flags, ws_bool_t &bAborted)
  421. {
  422. return shell_delete_a_(hwnd, from, NULL, flags, &bAborted);
  423. }
  424. /** \brief Requests the shell to delete the given file
  425. *
  426. * \ingroup group__library__windows_shell
  427. *
  428. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  429. * \param from The file to delete
  430. * \param progressTitle String to be displayed describing the operation
  431. *
  432. * \note Throws std::bad_alloc on allocation failure on translators that support it
  433. *
  434. * \note The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  435. *
  436. * \return A status code indicating the success of the operation
  437. *
  438. * \retval 0 The operation completed successfully
  439. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  440. * \retval !0 Any other Win32 error code
  441. */
  442. inline int shell_delete(HWND hwnd, ws_char_a_t const* from, ws_char_a_t const* progressTitle)
  443. {
  444. return shell_delete_a_(hwnd, from, progressTitle, 0, NULL);
  445. }
  446. /** \brief Requests the shell to delete the given file
  447. *
  448. * \ingroup group__library__windows_shell
  449. *
  450. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  451. * \param from The file to delete
  452. * \param progressTitle String to be displayed describing the operation
  453. * \param bAborted A Boolean that will indicate whether the operation was aborted
  454. *
  455. * \note Throws std::bad_alloc on allocation failure on translators that support it
  456. *
  457. * \note The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  458. *
  459. * \return A status code indicating the success of the operation
  460. *
  461. * \retval 0 The operation completed successfully
  462. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  463. * \retval !0 Any other Win32 error code
  464. */
  465. inline int shell_delete(HWND hwnd, ws_char_a_t const* from, ws_char_a_t const* progressTitle, ws_bool_t &bAborted)
  466. {
  467. return shell_delete_a_(hwnd, from, progressTitle, 0, &bAborted);
  468. }
  469. /** \brief Requests the shell to delete the given file
  470. *
  471. * \ingroup group__library__windows_shell
  472. *
  473. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  474. * \param from The file to delete
  475. * \param progressTitle String to be displayed describing the operation
  476. * \param flags One or more of the FILEOP_FLAGS values.
  477. *
  478. * \note Throws std::bad_alloc on allocation failure on translators that support it
  479. *
  480. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored. The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  481. *
  482. * \return A status code indicating the success of the operation
  483. *
  484. * \retval 0 The operation completed successfully
  485. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  486. * \retval !0 Any other Win32 error code
  487. */
  488. inline int shell_delete(HWND hwnd, ws_char_a_t const* from, ws_char_a_t const* progressTitle, FILEOP_FLAGS flags)
  489. {
  490. return shell_delete_a_(hwnd, from, progressTitle, flags, NULL);
  491. }
  492. /** \brief Requests the shell to delete the given file
  493. *
  494. * \ingroup group__library__windows_shell
  495. *
  496. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  497. * \param from The file to delete
  498. * \param progressTitle String to be displayed describing the operation
  499. * \param flags One or more of the FILEOP_FLAGS values.
  500. * \param bAborted A Boolean that will indicate whether the operation was aborted
  501. *
  502. * \note Throws std::bad_alloc on allocation failure on translators that support it
  503. *
  504. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored. The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  505. *
  506. * \return A status code indicating the success of the operation
  507. *
  508. * \retval 0 The operation completed successfully
  509. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  510. * \retval !0 Any other Win32 error code
  511. */
  512. inline int shell_delete(HWND hwnd, ws_char_a_t const* from, ws_char_a_t const* progressTitle, FILEOP_FLAGS flags, ws_bool_t &bAborted)
  513. {
  514. return shell_delete_a_(hwnd, from, progressTitle, flags, &bAborted);
  515. }
  516. /** \brief Requests the shell to delete the given file
  517. *
  518. * \ingroup group__library__windows_shell
  519. *
  520. * \param from The file to delete
  521. *
  522. * \note Throws std::bad_alloc on allocation failure on translators that support it
  523. *
  524. * \return A status code indicating the success of the operation
  525. *
  526. * \retval 0 The operation completed successfully
  527. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  528. * \retval !0 Any other Win32 error code
  529. */
  530. inline int shell_delete(ws_char_w_t const* from)
  531. {
  532. return shell_delete_w_(NULL, from, NULL, 0, NULL);
  533. }
  534. /** \brief Requests the shell to delete the given file
  535. *
  536. * \ingroup group__library__windows_shell
  537. *
  538. * \param from The file to delete
  539. * \param bAborted A Boolean that will indicate whether the operation was aborted
  540. *
  541. * \note Throws std::bad_alloc on allocation failure on translators that support it
  542. *
  543. * \return A status code indicating the success of the operation
  544. *
  545. * \retval 0 The operation completed successfully
  546. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  547. * \retval !0 Any other Win32 error code
  548. */
  549. inline int shell_delete(ws_char_w_t const* from, ws_bool_t &bAborted)
  550. {
  551. return shell_delete_w_(NULL, from, NULL, 0, &bAborted);
  552. }
  553. /** \brief Requests the shell to delete the given file
  554. *
  555. * \ingroup group__library__windows_shell
  556. *
  557. * \param from The file to delete
  558. * \param flags One or more of the FILEOP_FLAGS values.
  559. *
  560. * \note Throws std::bad_alloc on allocation failure on translators that support it
  561. *
  562. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored.
  563. *
  564. * \return A status code indicating the success of the operation
  565. *
  566. * \retval 0 The operation completed successfully
  567. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  568. * \retval !0 Any other Win32 error code
  569. */
  570. inline int shell_delete(ws_char_w_t const* from, FILEOP_FLAGS flags)
  571. {
  572. return shell_delete_w_(NULL, from, NULL, flags, NULL);
  573. }
  574. /** \brief Requests the shell to delete the given file
  575. *
  576. * \ingroup group__library__windows_shell
  577. *
  578. * \param from The file to delete
  579. * \param flags One or more of the FILEOP_FLAGS values.
  580. * \param bAborted A Boolean that will indicate whether the operation was aborted
  581. *
  582. * \note Throws std::bad_alloc on allocation failure on translators that support it
  583. *
  584. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored
  585. *
  586. * \return A status code indicating the success of the operation
  587. *
  588. * \retval 0 The operation completed successfully
  589. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  590. * \retval !0 Any other Win32 error code
  591. */
  592. inline int shell_delete(ws_char_w_t const* from, FILEOP_FLAGS flags, ws_bool_t &bAborted)
  593. {
  594. return shell_delete_w_(NULL, from, NULL, flags, &bAborted);
  595. }
  596. /** \brief Requests the shell to delete the given file
  597. *
  598. * \ingroup group__library__windows_shell
  599. *
  600. * \param from The file to delete
  601. * \param progressTitle String to be displayed describing the operation
  602. *
  603. * \note Throws std::bad_alloc on allocation failure on translators that support it
  604. *
  605. * \note The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  606. *
  607. * \return A status code indicating the success of the operation
  608. *
  609. * \retval 0 The operation completed successfully
  610. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  611. * \retval !0 Any other Win32 error code
  612. */
  613. inline int shell_delete(ws_char_w_t const* from, ws_char_w_t const* progressTitle)
  614. {
  615. return shell_delete_w_(NULL, from, progressTitle, 0, NULL);
  616. }
  617. /** \brief Requests the shell to delete the given file
  618. *
  619. * \ingroup group__library__windows_shell
  620. *
  621. * \param from The file to delete
  622. * \param progressTitle String to be displayed describing the operation
  623. * \param bAborted A Boolean that will indicate whether the operation was aborted
  624. *
  625. * \note Throws std::bad_alloc on allocation failure on translators that support it
  626. *
  627. * \note The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  628. *
  629. * \return A status code indicating the success of the operation
  630. *
  631. * \retval 0 The operation completed successfully
  632. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  633. * \retval !0 Any other Win32 error code
  634. */
  635. inline int shell_delete(ws_char_w_t const* from, ws_char_w_t const* progressTitle, ws_bool_t &bAborted)
  636. {
  637. return shell_delete_w_(NULL, from, progressTitle, 0, &bAborted);
  638. }
  639. /** \brief Requests the shell to delete the given file
  640. *
  641. * \ingroup group__library__windows_shell
  642. *
  643. * \param from The file to delete
  644. * \param progressTitle String to be displayed describing the operation
  645. * \param flags One or more of the FILEOP_FLAGS values.
  646. *
  647. * \note Throws std::bad_alloc on allocation failure on translators that support it
  648. *
  649. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored. The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  650. *
  651. * \return A status code indicating the success of the operation
  652. *
  653. * \retval 0 The operation completed successfully
  654. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  655. * \retval !0 Any other Win32 error code
  656. */
  657. inline int shell_delete(ws_char_w_t const* from, ws_char_w_t const* progressTitle, FILEOP_FLAGS flags)
  658. {
  659. return shell_delete_w_(NULL, from, progressTitle, flags, NULL);
  660. }
  661. /** \brief Requests the shell to delete the given file
  662. *
  663. * \ingroup group__library__windows_shell
  664. *
  665. * \param from The file to delete
  666. * \param progressTitle String to be displayed describing the operation
  667. * \param flags One or more of the FILEOP_FLAGS values.
  668. * \param bAborted A Boolean that will indicate whether the operation was aborted
  669. *
  670. * \note Throws std::bad_alloc on allocation failure on translators that support it
  671. *
  672. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored. The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  673. *
  674. * \return A status code indicating the success of the operation
  675. *
  676. * \retval 0 The operation completed successfully
  677. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  678. * \retval !0 Any other Win32 error code
  679. */
  680. inline int shell_delete(ws_char_w_t const* from, ws_char_w_t const* progressTitle, FILEOP_FLAGS flags, ws_bool_t &bAborted)
  681. {
  682. return shell_delete_w_(NULL, from, progressTitle, flags, &bAborted);
  683. }
  684. /** \brief Requests the shell to delete the given file
  685. *
  686. * \ingroup group__library__windows_shell
  687. *
  688. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  689. * \param from The file to delete
  690. *
  691. * \note Throws std::bad_alloc on allocation failure on translators that support it
  692. *
  693. * \return A status code indicating the success of the operation
  694. *
  695. * \retval 0 The operation completed successfully
  696. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  697. * \retval !0 Any other Win32 error code
  698. */
  699. inline int shell_delete(HWND hwnd, ws_char_w_t const* from)
  700. {
  701. return shell_delete_w_(hwnd, from, NULL, 0, NULL);
  702. }
  703. /** \brief Requests the shell to delete the given file
  704. *
  705. * \ingroup group__library__windows_shell
  706. *
  707. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  708. * \param from The file to delete
  709. * \param bAborted A Boolean that will indicate whether the operation was aborted
  710. *
  711. * \note Throws std::bad_alloc on allocation failure on translators that support it
  712. *
  713. * \return A status code indicating the success of the operation
  714. *
  715. * \retval 0 The operation completed successfully
  716. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  717. * \retval !0 Any other Win32 error code
  718. */
  719. inline int shell_delete(HWND hwnd, ws_char_w_t const* from, ws_bool_t &bAborted)
  720. {
  721. return shell_delete_w_(hwnd, from, NULL, 0, &bAborted);
  722. }
  723. /** \brief Requests the shell to delete the given file
  724. *
  725. * \ingroup group__library__windows_shell
  726. *
  727. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  728. * \param from The file to delete
  729. * \param flags One or more of the FILEOP_FLAGS values.
  730. *
  731. * \note Throws std::bad_alloc on allocation failure on translators that support it
  732. *
  733. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored.
  734. *
  735. * \return A status code indicating the success of the operation
  736. *
  737. * \retval 0 The operation completed successfully
  738. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  739. * \retval !0 Any other Win32 error code
  740. */
  741. inline int shell_delete(HWND hwnd, ws_char_w_t const* from, FILEOP_FLAGS flags)
  742. {
  743. return shell_delete_w_(hwnd, from, NULL, flags, NULL);
  744. }
  745. /** \brief Requests the shell to delete the given file
  746. *
  747. * \ingroup group__library__windows_shell
  748. *
  749. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  750. * \param from The file to delete
  751. * \param flags One or more of the FILEOP_FLAGS values.
  752. * \param bAborted A Boolean that will indicate whether the operation was aborted
  753. *
  754. * \note Throws std::bad_alloc on allocation failure on translators that support it
  755. *
  756. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored.
  757. *
  758. * \return A status code indicating the success of the operation
  759. *
  760. * \retval 0 The operation completed successfully
  761. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  762. * \retval !0 Any other Win32 error code
  763. */
  764. inline int shell_delete(HWND hwnd, ws_char_w_t const* from, FILEOP_FLAGS flags, ws_bool_t &bAborted)
  765. {
  766. return shell_delete_w_(hwnd, from, NULL, flags, &bAborted);
  767. }
  768. /** \brief Requests the shell to delete the given file
  769. *
  770. * \ingroup group__library__windows_shell
  771. *
  772. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  773. * \param from The file to delete
  774. * \param progressTitle String to be displayed describing the operation
  775. *
  776. * \note Throws std::bad_alloc on allocation failure on translators that support it
  777. *
  778. * \note The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  779. *
  780. * \return A status code indicating the success of the operation
  781. *
  782. * \retval 0 The operation completed successfully
  783. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  784. * \retval !0 Any other Win32 error code
  785. */
  786. inline int shell_delete(HWND hwnd, ws_char_w_t const* from, ws_char_w_t const* progressTitle)
  787. {
  788. return shell_delete_w_(hwnd, from, progressTitle, 0, NULL);
  789. }
  790. /** \brief Requests the shell to delete the given file
  791. *
  792. * \ingroup group__library__windows_shell
  793. *
  794. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  795. * \param from The file to delete
  796. * \param progressTitle String to be displayed describing the operation
  797. * \param bAborted A Boolean that will indicate whether the operation was aborted
  798. *
  799. * \note Throws std::bad_alloc on allocation failure on translators that support it
  800. *
  801. * \note The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  802. *
  803. * \return A status code indicating the success of the operation
  804. *
  805. * \retval 0 The operation completed successfully
  806. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  807. * \retval !0 Any other Win32 error code
  808. */
  809. inline int shell_delete(HWND hwnd, ws_char_w_t const* from, ws_char_w_t const* progressTitle, ws_bool_t &bAborted)
  810. {
  811. return shell_delete_w_(hwnd, from, progressTitle, 0, &bAborted);
  812. }
  813. /** \brief Requests the shell to delete the given file
  814. *
  815. * \ingroup group__library__windows_shell
  816. *
  817. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  818. * \param from The file to delete
  819. * \param progressTitle String to be displayed describing the operation
  820. * \param flags One or more of the FILEOP_FLAGS values.
  821. *
  822. * \note Throws std::bad_alloc on allocation failure on translators that support it
  823. *
  824. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored. The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  825. *
  826. * \return A status code indicating the success of the operation
  827. *
  828. * \retval 0 The operation completed successfully
  829. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  830. * \retval !0 Any other Win32 error code
  831. */
  832. inline int shell_delete(HWND hwnd, ws_char_w_t const* from, ws_char_w_t const* progressTitle, FILEOP_FLAGS flags)
  833. {
  834. return shell_delete_w_(hwnd, from, progressTitle, flags, NULL);
  835. }
  836. /** \brief Requests the shell to delete the given file
  837. *
  838. * \ingroup group__library__windows_shell
  839. *
  840. * \param hwnd Handle to the window that will act as the parent to any dialogs displayed
  841. * \param from The file to delete
  842. * \param progressTitle String to be displayed describing the operation
  843. * \param flags One or more of the FILEOP_FLAGS values.
  844. * \param bAborted A Boolean that will indicate whether the operation was aborted
  845. *
  846. * \note Throws std::bad_alloc on allocation failure on translators that support it
  847. *
  848. * \note The FOF_WANTMAPPINGHANDLE flag is always ignored. The flag FOF_SIMPLEPROGRESS is automatically added if progressTitle is non-NULL
  849. *
  850. * \return A status code indicating the success of the operation
  851. *
  852. * \retval 0 The operation completed successfully
  853. * \retval ERROR_NOT_ENOUGH_MEMORY This is returned only when compiling with translators that do not support throwing std::bad_alloc on memory allocation failure
  854. * \retval !0 Any other Win32 error code
  855. */
  856. inline int shell_delete(HWND hwnd, ws_char_w_t const* from, ws_char_w_t const* progressTitle, FILEOP_FLAGS flags, ws_bool_t &bAborted)
  857. {
  858. return shell_delete_w_(hwnd, from, progressTitle, flags, &bAborted);
  859. }
  860. ////////////////////////////////////////////////////////////////////////////
  861. // Unit-testing
  862. #ifdef STLSOFT_UNITTEST
  863. # include "./unittest/file_operations_unittest_.h"
  864. #endif /* STLSOFT_UNITTEST */
  865. /* ////////////////////////////////////////////////////////////////////// */
  866. #ifndef _WINSTL_NO_NAMESPACE
  867. # if defined(_STLSOFT_NO_NAMESPACE) || \
  868. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  869. } // namespace winstl
  870. # else
  871. } // namespace winstl_project
  872. } // namespace stlsoft
  873. # endif /* _STLSOFT_NO_NAMESPACE */
  874. #endif /* !_WINSTL_NO_NAMESPACE */
  875. /* ////////////////////////////////////////////////////////////////////// */
  876. #endif /* WINSTL_INCL_WINSTL_SHELL_HPP_FILE_OPERATIONS */
  877. /* ///////////////////////////// end of file //////////////////////////// */