MCPcopy Create free account
hub / github.com/derceg/explorerplusplus / RenameFiles

Method RenameFiles

Explorer++/Helper/FileActionHandler.cpp:15–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include "../Helper/Macros.h"
14
15BOOL FileActionHandler::RenameFiles(const RenamedItems_t &itemList)
16{
17 RenamedItems_t renamedItems;
18
19 for(const auto &item : itemList)
20 {
21 /* TODO: This should actually be done by the caller. */
22 IShellItem *shellItem = nullptr;
23 HRESULT hr = SHCreateItemFromParsingName(item.strOldFilename.c_str(), nullptr, IID_PPV_ARGS(&shellItem));
24
25 if (SUCCEEDED(hr))
26 {
27 TCHAR newFilename[MAX_PATH];
28 StringCchCopy(newFilename, SIZEOF_ARRAY(newFilename), item.strNewFilename.c_str());
29 PathStripPath(newFilename);
30
31 /* TODO: Could rename all files in the list in a single
32 operation, rather than one by one.*/
33 hr = NFileOperations::RenameFile(shellItem, newFilename);
34
35 if (SUCCEEDED(hr))
36 {
37 renamedItems.push_back(item);
38 }
39
40 shellItem->Release();
41 }
42 }
43
44 /* Only store an undo operation if at least one
45 file was actually renamed. */
46 if(!renamedItems.empty())
47 {
48 UndoItem_t undoItem;
49 undoItem.Type = FILE_ACTION_RENAMED;
50 undoItem.renamedItems = renamedItems;
51 m_stackFileActions.push(undoItem);
52
53 return TRUE;
54 }
55
56 return FALSE;
57}
58
59HRESULT FileActionHandler::DeleteFiles(HWND hwnd, DeletedItems_t &deletedItems,
60 bool permanent, bool silent)

Callers 3

OnOkMethod · 0.80

Calls 4

c_strMethod · 0.80
ReleaseMethod · 0.45
emptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected