00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00050 #ifndef WINSTL_INCL_WINSTL_SHELL_HPP_FILE_OPERATIONS
00051 #define WINSTL_INCL_WINSTL_SHELL_HPP_FILE_OPERATIONS
00052
00053 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00054 # define WINSTL_VER_WINSTL_SHELL_HPP_FILE_OPERATIONS_MAJOR 2
00055 # define WINSTL_VER_WINSTL_SHELL_HPP_FILE_OPERATIONS_MINOR 1
00056 # define WINSTL_VER_WINSTL_SHELL_HPP_FILE_OPERATIONS_REVISION 3
00057 # define WINSTL_VER_WINSTL_SHELL_HPP_FILE_OPERATIONS_EDIT 89
00058 #endif
00059
00060
00061
00062
00063
00064 #ifndef WINSTL_INCL_WINSTL_H_WINSTL
00065 # include <winstl/winstl.h>
00066 #endif
00067 #ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_SHELL_ALLOCATOR
00068 # include <winstl/memory/shell_allocator.hpp>
00069 #endif
00070 #ifndef STLSOFT_INCL_STLSOFT_MEMORY_HPP_AUTO_BUFFER
00071 # include <stlsoft/memory/auto_buffer.hpp>
00072 #endif
00073
00074
00075
00076
00077
00078
00079 #ifndef STLSOFT_INCL_STLSOFT_HPP_AUTO_BUFFER
00080 # include <winstl/winstl.h>
00081 #endif
00082
00083
00084
00085
00086
00087 #ifndef _WINSTL_NO_NAMESPACE
00088 # if defined(_STLSOFT_NO_NAMESPACE) || \
00089 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00090
00091 namespace winstl
00092 {
00093 # else
00094
00095
00096 namespace stlsoft
00097 {
00098
00099 namespace winstl_project
00100 {
00101
00102 # endif
00103 #endif
00104
00105
00106
00107
00108
00109 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00110
00111 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)
00112 {
00113 WINSTL_MESSAGE_ASSERT("Null string cannot be specified", NULL != from);
00114
00115 typedef auto_buffer<ws_char_a_t, 2 + WINSTL_CONST_MAX_PATH, shell_allocator<ws_char_a_t> > buffer_t;
00116
00117 ws_size_t cch = static_cast<ws_size_t>(::lstrlenA(from));
00118 buffer_t buff(1 + cch + 1);
00119
00120 if(buff.empty())
00121 {
00122 ::SetLastError(ERROR_NOT_ENOUGH_MEMORY);
00123
00124 return ERROR_NOT_ENOUGH_MEMORY;
00125 }
00126 else
00127 {
00128 SHFILEOPSTRUCTA sos;
00129
00130 ::lstrcpyA(&buff[0], from);
00131 buff[cch + 1] = '\0';
00132
00133 flags &= ~(FOF_WANTMAPPINGHANDLE);
00134 flags |= static_cast<FILEOP_FLAGS>((NULL == progressTitle) ? 0 : FOF_SIMPLEPROGRESS);
00135
00136 sos.hwnd = hwnd;
00137 sos.wFunc = FO_DELETE;
00138 sos.pFrom = buff.data();
00139 sos.pTo = NULL;
00140 sos.fFlags = flags;
00141 sos.fAnyOperationsAborted = false;
00142 sos.hNameMappings = NULL;
00143 sos.lpszProgressTitle = progressTitle;
00144
00145 int res = ::SHFileOperationA(&sos);
00146
00147 if(0 == res)
00148 {
00149 if(NULL != pbAborted)
00150 {
00151 *pbAborted = (FALSE != sos.fAnyOperationsAborted);
00152 }
00153 }
00154
00155 return res;
00156 }
00157 }
00158
00159 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)
00160 {
00161 WINSTL_MESSAGE_ASSERT("Null string cannot be specified", NULL != from);
00162
00163 typedef auto_buffer<ws_char_w_t, 2 + WINSTL_CONST_MAX_PATH, shell_allocator<ws_char_w_t> > buffer_t;
00164
00165 ws_size_t cch = static_cast<ws_size_t>(::lstrlenW(from));
00166 buffer_t buff(1 + cch + 1);
00167
00168 if(buff.empty())
00169 {
00170 ::SetLastError(ERROR_NOT_ENOUGH_MEMORY);
00171
00172 return ERROR_NOT_ENOUGH_MEMORY;
00173 }
00174 else
00175 {
00176 SHFILEOPSTRUCTW sos;
00177
00178 ::lstrcpyW(&buff[0], from);
00179 buff[cch + 1] = '\0';
00180
00181 flags &= ~(FOF_WANTMAPPINGHANDLE);
00182 flags |= static_cast<FILEOP_FLAGS>((NULL == progressTitle) ? 0 : FOF_SIMPLEPROGRESS);
00183
00184 sos.hwnd = hwnd;
00185 sos.wFunc = FO_DELETE;
00186 sos.pFrom = buff.data();
00187 sos.pTo = NULL;
00188 sos.fFlags = flags;
00189 sos.fAnyOperationsAborted = false;
00190 sos.hNameMappings = NULL;
00191 sos.lpszProgressTitle = progressTitle;
00192
00193 int res = ::SHFileOperationW(&sos);
00194
00195 if(0 == res)
00196 {
00197 if(NULL != pbAborted)
00198 {
00199 *pbAborted = (FALSE != sos.fAnyOperationsAborted);
00200 }
00201 }
00202
00203 return res;
00204 }
00205 }
00206
00207 #endif
00208
00223 inline int shell_delete(ws_char_a_t const* from)
00224 {
00225 return shell_delete_a_(NULL, from, NULL, 0, NULL);
00226 }
00227
00243 inline int shell_delete(ws_char_a_t const* from, ws_bool_t &bAborted)
00244 {
00245 return shell_delete_a_(NULL, from, NULL, 0, &bAborted);
00246 }
00247
00265 inline int shell_delete(ws_char_a_t const* from, FILEOP_FLAGS flags)
00266 {
00267 return shell_delete_a_(NULL, from, NULL, flags, NULL);
00268 }
00269
00288 inline int shell_delete(ws_char_a_t const* from, FILEOP_FLAGS flags, ws_bool_t &bAborted)
00289 {
00290 return shell_delete_a_(NULL, from, NULL, flags, &bAborted);
00291 }
00292
00310 inline int shell_delete(ws_char_a_t const* from, ws_char_a_t const* progressTitle)
00311 {
00312 return shell_delete_a_(NULL, from, progressTitle, 0, NULL);
00313 }
00314
00333 inline int shell_delete(ws_char_a_t const* from, ws_char_a_t const* progressTitle, ws_bool_t &bAborted)
00334 {
00335 return shell_delete_a_(NULL, from, progressTitle, 0, &bAborted);
00336 }
00337
00356 inline int shell_delete(ws_char_a_t const* from, ws_char_a_t const* progressTitle, FILEOP_FLAGS flags)
00357 {
00358 return shell_delete_a_(NULL, from, progressTitle, flags, NULL);
00359 }
00360
00380 inline int shell_delete(ws_char_a_t const* from, ws_char_a_t const* progressTitle, FILEOP_FLAGS flags, ws_bool_t &bAborted)
00381 {
00382 return shell_delete_a_(NULL, from, progressTitle, flags, &bAborted);
00383 }
00384
00400 inline int shell_delete(HWND hwnd, ws_char_a_t const* from)
00401 {
00402 return shell_delete_a_(hwnd, from, NULL, 0, NULL);
00403 }
00404
00421 inline int shell_delete(HWND hwnd, ws_char_a_t const* from, ws_bool_t &bAborted)
00422 {
00423 return shell_delete_a_(hwnd, from, NULL, 0, &bAborted);
00424 }
00425
00444 inline int shell_delete(HWND hwnd, ws_char_a_t const* from, FILEOP_FLAGS flags)
00445 {
00446 return shell_delete_a_(hwnd, from, NULL, flags, NULL);
00447 }
00448
00468 inline int shell_delete(HWND hwnd, ws_char_a_t const* from, FILEOP_FLAGS flags, ws_bool_t &bAborted)
00469 {
00470 return shell_delete_a_(hwnd, from, NULL, flags, &bAborted);
00471 }
00472
00491 inline int shell_delete(HWND hwnd, ws_char_a_t const* from, ws_char_a_t const* progressTitle)
00492 {
00493 return shell_delete_a_(hwnd, from, progressTitle, 0, NULL);
00494 }
00495
00515 inline int shell_delete(HWND hwnd, ws_char_a_t const* from, ws_char_a_t const* progressTitle, ws_bool_t &bAborted)
00516 {
00517 return shell_delete_a_(hwnd, from, progressTitle, 0, &bAborted);
00518 }
00519
00539 inline int shell_delete(HWND hwnd, ws_char_a_t const* from, ws_char_a_t const* progressTitle, FILEOP_FLAGS flags)
00540 {
00541 return shell_delete_a_(hwnd, from, progressTitle, flags, NULL);
00542 }
00543
00564 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)
00565 {
00566 return shell_delete_a_(hwnd, from, progressTitle, flags, &bAborted);
00567 }
00568
00569
00570
00585 inline int shell_delete(ws_char_w_t const* from)
00586 {
00587 return shell_delete_w_(NULL, from, NULL, 0, NULL);
00588 }
00589
00605 inline int shell_delete(ws_char_w_t const* from, ws_bool_t &bAborted)
00606 {
00607 return shell_delete_w_(NULL, from, NULL, 0, &bAborted);
00608 }
00609
00627 inline int shell_delete(ws_char_w_t const* from, FILEOP_FLAGS flags)
00628 {
00629 return shell_delete_w_(NULL, from, NULL, flags, NULL);
00630 }
00631
00650 inline int shell_delete(ws_char_w_t const* from, FILEOP_FLAGS flags, ws_bool_t &bAborted)
00651 {
00652 return shell_delete_w_(NULL, from, NULL, flags, &bAborted);
00653 }
00654
00672 inline int shell_delete(ws_char_w_t const* from, ws_char_w_t const* progressTitle)
00673 {
00674 return shell_delete_w_(NULL, from, progressTitle, 0, NULL);
00675 }
00676
00695 inline int shell_delete(ws_char_w_t const* from, ws_char_w_t const* progressTitle, ws_bool_t &bAborted)
00696 {
00697 return shell_delete_w_(NULL, from, progressTitle, 0, &bAborted);
00698 }
00699
00718 inline int shell_delete(ws_char_w_t const* from, ws_char_w_t const* progressTitle, FILEOP_FLAGS flags)
00719 {
00720 return shell_delete_w_(NULL, from, progressTitle, flags, NULL);
00721 }
00722
00742 inline int shell_delete(ws_char_w_t const* from, ws_char_w_t const* progressTitle, FILEOP_FLAGS flags, ws_bool_t &bAborted)
00743 {
00744 return shell_delete_w_(NULL, from, progressTitle, flags, &bAborted);
00745 }
00746
00762 inline int shell_delete(HWND hwnd, ws_char_w_t const* from)
00763 {
00764 return shell_delete_w_(hwnd, from, NULL, 0, NULL);
00765 }
00766
00783 inline int shell_delete(HWND hwnd, ws_char_w_t const* from, ws_bool_t &bAborted)
00784 {
00785 return shell_delete_w_(hwnd, from, NULL, 0, &bAborted);
00786 }
00787
00806 inline int shell_delete(HWND hwnd, ws_char_w_t const* from, FILEOP_FLAGS flags)
00807 {
00808 return shell_delete_w_(hwnd, from, NULL, flags, NULL);
00809 }
00810
00830 inline int shell_delete(HWND hwnd, ws_char_w_t const* from, FILEOP_FLAGS flags, ws_bool_t &bAborted)
00831 {
00832 return shell_delete_w_(hwnd, from, NULL, flags, &bAborted);
00833 }
00834
00853 inline int shell_delete(HWND hwnd, ws_char_w_t const* from, ws_char_w_t const* progressTitle)
00854 {
00855 return shell_delete_w_(hwnd, from, progressTitle, 0, NULL);
00856 }
00857
00877 inline int shell_delete(HWND hwnd, ws_char_w_t const* from, ws_char_w_t const* progressTitle, ws_bool_t &bAborted)
00878 {
00879 return shell_delete_w_(hwnd, from, progressTitle, 0, &bAborted);
00880 }
00881
00901 inline int shell_delete(HWND hwnd, ws_char_w_t const* from, ws_char_w_t const* progressTitle, FILEOP_FLAGS flags)
00902 {
00903 return shell_delete_w_(hwnd, from, progressTitle, flags, NULL);
00904 }
00905
00926 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)
00927 {
00928 return shell_delete_w_(hwnd, from, progressTitle, flags, &bAborted);
00929 }
00930
00931
00933
00934
00935 #ifdef STLSOFT_UNITTEST
00936 # include "./unittest/file_operations_unittest_.h"
00937 #endif
00938
00939
00940
00941 #ifndef _WINSTL_NO_NAMESPACE
00942 # if defined(_STLSOFT_NO_NAMESPACE) || \
00943 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00944 }
00945 # else
00946 }
00947 }
00948 # endif
00949 #endif
00950
00951
00952
00953 #endif
00954
00955