├── data ├── file_id.diz ├── english.lng ├── spanish.lng ├── Russian.hlf ├── russian.lng └── resource │ ├── russian.locd │ ├── spanish.locd │ └── english.locd ├── TODO.Txt ├── src ├── vc10.asm ├── vc10.cpp ├── SDK │ ├── plugin.hpp │ ├── farcolor.hpp │ └── farversion.hpp ├── vc10wrapper.cpp ├── Framework │ ├── LocaleUtils.h │ ├── Payload.cpp │ ├── LocaleUtils.cpp │ ├── FileNameStoreEnum.h │ ├── ObjectManager.cpp │ ├── CastNode.h │ ├── StringParent.h │ ├── ObjectManager.h │ ├── Payload.h │ ├── StringVector.h │ ├── DescList.h │ ├── StrUtils.h │ ├── FrameworkUtils.h │ ├── StdHdr.h │ ├── FrameworkUtils.cpp │ ├── FileNameStore.h │ ├── FileNameStoreEnum.cpp │ ├── Node.h │ ├── Properties.h │ ├── FileUtils.h │ ├── Properties.cpp │ ├── ObjString.cpp │ ├── DescList.cpp │ ├── Node.cpp │ ├── ObjString.h │ ├── StrUtils.cpp │ └── StringParent.cpp ├── FarMacro.h ├── version.hpp ├── FarMenu.h ├── FarSettings.h ├── guid.hpp ├── taskbarIcon.h ├── Common.h ├── ui.h ├── FarPlugin.h ├── CopyProgress.h ├── taskbarIcon.cpp ├── FarProgress.h ├── FarMenu.cpp ├── common.cpp ├── EngineTools.h ├── FarMacro.cpp ├── FarNode.h ├── FileCopyEx.cpp ├── tools.h ├── FarSettings.cpp ├── ui.cpp ├── Engine.h ├── FarPayload.h ├── tools.cpp ├── FarPayload.cpp ├── EngineTools.cpp ├── FarNode.cpp ├── CopyProgress.cpp └── FarProgress.cpp ├── FileCopyEx3.rc ├── plugin.def ├── testDebug.cmd ├── testRelease.cmd ├── plugin.gcc.def ├── .gitignore ├── LICENSE.txt ├── FileCopyEx3.sln ├── FileCopyEx3.vc10.sln ├── make_dist.cmd ├── README.md ├── changelog.txt └── CMakeLists.txt /data/file_id.diz: -------------------------------------------------------------------------------- 1 | [x86/x64] File copy plugin v3.0.3 beta -------------------------------------------------------------------------------- /TODO.Txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/filecopyex3/master/TODO.Txt -------------------------------------------------------------------------------- /data/english.lng: -------------------------------------------------------------------------------- 1 | .Language=English,English 2 | 3 | "English.locd" 4 | -------------------------------------------------------------------------------- /data/spanish.lng: -------------------------------------------------------------------------------- 1 | .Language=Spanish,Spanish 2 | 3 | "Spanish.locd" 4 | -------------------------------------------------------------------------------- /src/vc10.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/filecopyex3/master/src/vc10.asm -------------------------------------------------------------------------------- /src/vc10.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/filecopyex3/master/src/vc10.cpp -------------------------------------------------------------------------------- /data/Russian.hlf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/filecopyex3/master/data/Russian.hlf -------------------------------------------------------------------------------- /data/russian.lng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/filecopyex3/master/data/russian.lng -------------------------------------------------------------------------------- /src/SDK/plugin.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/filecopyex3/master/src/SDK/plugin.hpp -------------------------------------------------------------------------------- /src/SDK/farcolor.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/filecopyex3/master/src/SDK/farcolor.hpp -------------------------------------------------------------------------------- /src/vc10wrapper.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/filecopyex3/master/src/vc10wrapper.cpp -------------------------------------------------------------------------------- /src/SDK/farversion.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/filecopyex3/master/src/SDK/farversion.hpp -------------------------------------------------------------------------------- /data/resource/russian.locd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/filecopyex3/master/data/resource/russian.locd -------------------------------------------------------------------------------- /data/resource/spanish.locd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/release/filecopyex3/master/data/resource/spanish.locd -------------------------------------------------------------------------------- /FileCopyEx3.rc: -------------------------------------------------------------------------------- 1 | #include "src/version.hpp" 2 | 3 | genericpluginrc(PLUGIN_BUILD, PLUGIN_DESC, PLUGIN_NAME, PLUGIN_FILENAME) 4 | -------------------------------------------------------------------------------- /plugin.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | SetStartupInfoW 3 | GetPluginInfoW 4 | OpenW 5 | ConfigureW 6 | ExitFARW 7 | GetGlobalInfoW 8 | -------------------------------------------------------------------------------- /testDebug.cmd: -------------------------------------------------------------------------------- 1 | copy "Debug Unicode\x64\FileCopyEx64.dll" "..\fardev\unicode_far\Debug.64.vc\Plugins\FileCopyEx\" 2 | cd "..\fardev\unicode_far\Debug.64.vc" 3 | start far.exe -------------------------------------------------------------------------------- /testRelease.cmd: -------------------------------------------------------------------------------- 1 | copy "Release Unicode\x64\FileCopyEx64.dll" "..\fardev\unicode_far\Debug.64.vc\Plugins\FileCopyEx\" 2 | cd "..\fardev\unicode_far\Debug.64.vc" 3 | start far.exe -------------------------------------------------------------------------------- /src/Framework/LocaleUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "StdHdr.h" 6 | #include "ObjString.h" 7 | 8 | typedef std::map Locale; 9 | void LoadLocale(const String & fn, Locale & locale); 10 | -------------------------------------------------------------------------------- /plugin.gcc.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | GetMinFarVersionW=GetMinFarVersionW@0 3 | SetStartupInfoW=SetStartupInfoW@4 4 | GetPluginInfoW=GetPluginInfoW@4 5 | OpenPluginW=OpenPluginW@8 6 | ClosePluginW=ClosePluginW@4 7 | ConfigureW=ConfigureW@4 8 | ExitFARW=ExitFARW@0 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /ipch/ 2 | /Debug Unicode/ 3 | /Release Unicode/ 4 | /My */ 5 | /Far3_x86/ 6 | /Far3_x64/ 7 | /build/ 8 | *.opensdf 9 | *.sdf 10 | *.suo 11 | /filecopyex3-build/ 12 | 13 | *.orig 14 | 15 | CMakeLists.txt.user 16 | *.vcxproj.user 17 | *.vcxproj.filters 18 | *.vcproj.user 19 | -------------------------------------------------------------------------------- /src/FarMacro.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Framework/ObjString.h" 4 | 5 | void Bind(const String & key, const String & code, const String & desc, int id); 6 | int Bound(const String & key); 7 | void Unbind(const String & key); 8 | 9 | String GetMacrosPath(uintptr_t PluginBuildNumber); 10 | String GetMacroFileName(const String & Key); 11 | void RemoveMacroFile(const String & MacrosPath, const String & Key); 12 | -------------------------------------------------------------------------------- /src/Framework/Payload.cpp: -------------------------------------------------------------------------------- 1 | #include "Payload.h" 2 | 3 | void Payload::addProperty(const String & AName, int def) 4 | { 5 | prop[AName] = def; 6 | } 7 | 8 | void Payload::addProperty(const String & AName, float def) 9 | { 10 | prop[AName] = def; 11 | } 12 | 13 | void Payload::addProperty(const String & AName, const String & def) 14 | { 15 | prop[AName] = def; 16 | } 17 | 18 | void Payload::init(const String & AName) 19 | { 20 | name = AName; 21 | } 22 | -------------------------------------------------------------------------------- /src/Framework/LocaleUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "LocaleUtils.h" 2 | 3 | #include "StringVector.h" 4 | 5 | void LoadLocale(const String & fn, Locale & locale) 6 | { 7 | StringVector temp; 8 | if (temp.loadFromFile(fn)) 9 | { 10 | for (size_t Index = 0; Index < temp.Count(); Index++) 11 | { 12 | const String & it = temp[Index]; 13 | size_t p = it.find(L"="); 14 | if (p != (size_t)-1) 15 | { 16 | locale[it.substr(0, p).trim().trimquotes()] = it.substr(p + 1).trim().trimquotes(); 17 | } 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Framework/FileNameStoreEnum.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "FileNameStore.h" 4 | #include "ObjString.h" 5 | 6 | class FileNameStoreEnum 7 | { 8 | private: 9 | FileNameStore * store; 10 | size_t cur; 11 | String curPath, buffer; 12 | 13 | public: 14 | FileNameStoreEnum(FileNameStore * _store) : store(_store) 15 | { 16 | ToFirst(); 17 | } 18 | ~FileNameStoreEnum() {} 19 | 20 | size_t Count() const { return store->Count(); } 21 | void ToFirst(); 22 | void Skip(); 23 | String GetNext(); 24 | String GetByNum(size_t num); 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /src/Framework/ObjectManager.cpp: -------------------------------------------------------------------------------- 1 | #include "ObjectManager.h" 2 | 3 | ObjectManager * objectManager; 4 | 5 | ObjectManager::~ObjectManager() 6 | { 7 | } 8 | 9 | void ObjectManager::regClass(const String & type, createPayloadFunc pf, createNodeFunc nf) 10 | { 11 | classes[type] = createFuncs(pf, nf); 12 | } 13 | 14 | Node * ObjectManager::create(const String & type, const String & name, Node * parent) 15 | { 16 | createFuncs cf = classes[type]; 17 | if (cf.nf && cf.pf) 18 | { 19 | Payload * payload = (*cf.pf)(); 20 | payload->init(name); 21 | Node * node = (*cf.nf)(); 22 | node->init(payload, parent); 23 | return node; 24 | } 25 | return nullptr; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/Framework/CastNode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Node.h" 4 | 5 | template 6 | class CastNode : public Node 7 | { 8 | public: 9 | ParentType * Parent() { return static_cast(parent); } 10 | ChildType & operator[](size_t i) { return child(i); } 11 | ChildType & operator[](const String & name) { return child(name); } 12 | PayloadType & getPayload() const { return static_cast(Node::getPayload()); } 13 | 14 | protected: 15 | ChildType & child(size_t i) { return static_cast(Node::child(i)); } 16 | ChildType & child(const String & name) { return static_cast(Node::child(name)); } 17 | }; 18 | -------------------------------------------------------------------------------- /src/version.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SDK/farversion.hpp" 4 | 5 | #define PLUGIN_MIN_FAR_VERSION MAKEFARVERSION(3, 0, 0, 4040, VS_RELEASE) // http://api.farmanager.com/ru/whatsnew.html 6 | #define PLUGIN_VERSION_TXT "3.0.8.39" 7 | #define PLUGIN_MAJOR 3 8 | #define PLUGIN_MINOR 0 9 | #define PLUGIN_SUBMINOR 8 10 | #define PLUGIN_BUILD 39 11 | #define PLUGIN_VERSION MAKEFARVERSION(PLUGIN_MAJOR, PLUGIN_MINOR, PLUGIN_SUBMINOR, PLUGIN_BUILD, VS_BETA) 12 | #define PLUGIN_DESC L"File Copy Extended plugin for Far 3 file manager main executable" 13 | #define PLUGIN_NAME L"FileCopyEx3" 14 | #define PLUGIN_TITLE L"FileCopyEx3" 15 | #define PLUGIN_FILENAME L"FileCopyEx3.dll" 16 | #define PLUGIN_AUTHOR L"Michael Lukashov, Igor Yudintsev, djdron, craZZy, Max Antipin and others" 17 | -------------------------------------------------------------------------------- /src/FarMenu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Framework/ObjString.h" 6 | #include "SDK/plugin.hpp" 7 | 8 | class FarMenu 9 | { 10 | public: 11 | FarMenu(); 12 | virtual ~FarMenu(); 13 | 14 | void SetTitle(const String &); 15 | void SetBottom(const String &); 16 | void SetHelpTopic(const String &); 17 | void SetFlags(DWORD f); 18 | void AddLine(const String &); 19 | void AddLineCheck(const String &, int check); 20 | void AddSep(); 21 | void SetSelection(size_t n); 22 | intptr_t Execute(); 23 | 24 | protected: 25 | String Title, Bottom, HelpTopic; 26 | DWORD Flags; 27 | size_t Selection; 28 | std::vector items; 29 | 30 | static void SetItemText(FarMenuItem * item, const String & text); 31 | }; 32 | -------------------------------------------------------------------------------- /src/Framework/StringParent.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "StdHdr.h" 4 | #include "ObjString.h" 5 | 6 | enum TextFormat { tfOEM, tfUnicode, tfUnicodeBE }; 7 | 8 | class StringParent 9 | { 10 | public: 11 | StringParent() {} 12 | virtual ~StringParent() {} 13 | 14 | virtual void Clear() = 0; 15 | virtual const String & operator[](size_t) const = 0; 16 | virtual void AddString(const String &) = 0; 17 | virtual size_t Count() const = 0; 18 | 19 | bool loadFromFile(FILE * f); 20 | bool loadFromFile(const String & fileName); 21 | void loadFromString(const String &, wchar_t delim); 22 | void loadFromString(const wchar_t *, wchar_t delim); 23 | 24 | bool saveToFile(FILE * f, TextFormat tf = tfOEM) const; 25 | bool saveToFile(const String & fileName, TextFormat tf = tfOEM); 26 | }; 27 | -------------------------------------------------------------------------------- /src/Framework/ObjectManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Payload.h" 4 | #include "Node.h" 5 | 6 | class ObjectManager 7 | { 8 | public: 9 | ~ObjectManager(); 10 | 11 | typedef Payload * createPayloadFunc(); 12 | typedef Node * createNodeFunc(); 13 | 14 | void regClass(const String & type, createPayloadFunc pf, createNodeFunc nf); 15 | Node * create(const String & type, const String & name, Node * parent); 16 | 17 | private: 18 | class createFuncs 19 | { 20 | public: 21 | createPayloadFunc * pf; 22 | createNodeFunc * nf; 23 | 24 | createFuncs() : pf(nullptr), nf(nullptr) {} 25 | createFuncs(createPayloadFunc * _pf, createNodeFunc * _nf) : 26 | pf(_pf), 27 | nf(_nf) 28 | {} 29 | }; 30 | 31 | std::map classes; 32 | }; 33 | 34 | extern ObjectManager * objectManager; 35 | 36 | -------------------------------------------------------------------------------- /src/Framework/Payload.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Node.h" 4 | 5 | class Payload 6 | { 7 | public: 8 | Payload() {} 9 | virtual ~Payload() {} 10 | 11 | virtual void init(const String & AName); 12 | 13 | void addProperty(const String & AName, int def); 14 | void addProperty(const String & AName, float def); 15 | void addProperty(const String & AName, const String & def); 16 | Property & operator()(const String & AName) { return getProp(AName); } 17 | 18 | const String getName() const { return name; } 19 | 20 | void propSave() { propSaved = prop; } 21 | void propLoad() { prop = propSaved; } 22 | 23 | protected: 24 | Property & getProp(const String & AName) { return prop[AName]; } 25 | 26 | PropertyMap prop; 27 | PropertyMap propSaved; 28 | String name; 29 | }; 30 | 31 | #define DEFINE_CLASS(name, type) \ 32 | static Payload* create() { return new type; } 33 | 34 | //virtual const String getType() { return ; } 35 | -------------------------------------------------------------------------------- /src/Framework/StringVector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "StringParent.h" 6 | 7 | class StringVector : public StringParent 8 | { 9 | public: 10 | StringVector() {} 11 | virtual ~StringVector() {} 12 | 13 | virtual void Clear() { data.clear(); } 14 | virtual const String & operator[](size_t i) const { return data[i]; } 15 | virtual void AddString(const String & v) { data.push_back(v); } 16 | virtual size_t Count() const { return data.size(); } 17 | intptr_t Find(const String & v, intptr_t start = 0) const 18 | { 19 | for (size_t Index = start; Index < Count(); ++Index) 20 | { 21 | if (data[Index].cmp(v) == 0) 22 | return Index; 23 | } 24 | return -1; 25 | } 26 | 27 | intptr_t FindAny(const String & v, intptr_t start = 0) const 28 | { 29 | for (size_t Index = start; Index < Count(); ++Index) 30 | { 31 | if (data[Index].find(v) != size_t(-1)) 32 | return Index; 33 | } 34 | return -1; 35 | } 36 | 37 | private: 38 | std::vector data; 39 | }; 40 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 2 | 3 | Copyright (C) 2004 - 2014 4 | Idea & core: Max Antipin 5 | Coding: Serge Cheperis aka craZZy 6 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 7 | Special thanks to Vitaliy Tsubin 8 | Far 2 (32 & 64 bit) full unicode version by djdron 9 | Far 3 (32 & 64 bit) Ruslan Petrenko (ruslanp@ruslanp.com), Michael Lukashov (michael.lukashov@gmail.com) 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | -------------------------------------------------------------------------------- /src/Framework/DescList.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "StringVector.h" 6 | 7 | class DescList 8 | { 9 | public: 10 | DescList(); 11 | bool LoadFromFile(const String & fn); 12 | void Merge(DescList &); 13 | bool SaveToFile(const String & fn); 14 | void SetAllMergeFlags(int v); 15 | void SetAllSaveFlags(int v); 16 | void SetMergeFlag(const String &, uint32_t v); 17 | void SetSaveFlag(const String &, uint32_t v); 18 | void Rename(const String & src, const String & dst, int changeName = 0); 19 | 20 | private: 21 | void setFlag(const String &, uint32_t flag, uint32_t v); 22 | void setAllFlags(uint32_t flag, uint32_t v); 23 | 24 | class Data 25 | { 26 | public: 27 | String desc; 28 | uint32_t flags; 29 | 30 | Data() : flags(0) {} 31 | Data(const String & _desc, int _flags = 0) : 32 | desc(_desc), 33 | flags(_flags) 34 | {} 35 | }; 36 | typedef std::map DescListMap; 37 | DescListMap names; 38 | 39 | bool LoadFromString(wchar_t * ptr); 40 | bool LoadFromList(StringVector & list); 41 | }; 42 | -------------------------------------------------------------------------------- /src/FarSettings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "SDK/plugin.hpp" 5 | #include "Framework/Properties.h" 6 | 7 | class FarSettings 8 | { 9 | public: 10 | FarSettings(); 11 | ~FarSettings(); 12 | 13 | bool attach(); 14 | void detach(); 15 | bool get(const String & name, String & value); 16 | bool set(const String & name, const String & value); 17 | 18 | class ParamInfo 19 | { 20 | public: 21 | String name; 22 | FARSETTINGSTYPES type; 23 | 24 | ParamInfo() : 25 | name(), 26 | type(FST_UNKNOWN) 27 | {} 28 | ParamInfo(const String & _name, FARSETTINGSTYPES _type) : 29 | name(_name), 30 | type(_type) 31 | {} 32 | }; 33 | typedef std::vector ParamInfoVector; 34 | 35 | bool list(ParamInfoVector & res); 36 | private: 37 | HANDLE handle; 38 | intptr_t dirId; 39 | int nAttachments; 40 | 41 | intptr_t control(FAR_SETTINGS_CONTROL_COMMANDS cmd, void * param = nullptr); 42 | }; 43 | 44 | bool saveOptions(const PropertyMap & options, FarSettings & settings); 45 | bool loadOptions(PropertyMap & options, FarSettings & settings); 46 | -------------------------------------------------------------------------------- /src/guid.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define INITGUID 4 | #include 5 | 6 | // {16990c75-cb7a-43df-8d7e-d6bf3683c3f1} 7 | DEFINE_GUID(MainGuid, 0x16990c75, 0xcb7a, 0x43df, 0x8d, 0x7e, 0xd6, 0xbf, 0x36, 0x83, 0xc3, 0xf1); 8 | 9 | // {12a865b9-bece-4b44-b92f-96e864c81e35} 10 | DEFINE_GUID(MenuGuid, 0x12a865b9, 0xbece, 0x4b44, 0xb9, 0x2f, 0x96, 0xe8, 0x64, 0xc8, 0x1e, 0x35); 11 | 12 | // {42842189-efe5-4f5b-883b-8add188e194e} 13 | DEFINE_GUID(ConfigGuid, 0x42842189, 0xefe5, 0x4f5b, 0x88, 0x3b, 0x8a, 0xdd, 0x18, 0x8e, 0x19, 0x4e); 14 | 15 | // {fad64ec6-565f-466b-a1f0-52739eb74778} 16 | DEFINE_GUID(MainDialog, 0xfad64ec6, 0x565f, 0x466b, 0xa1, 0xf0, 0x52, 0x73, 0x9e, 0xb7, 0x47, 0x78); 17 | 18 | // {7f244164-d2b4-4e6a-9cdb-922744901f2c} 19 | DEFINE_GUID(ProgressDlg, 0x7f244164, 0xd2b4, 0x4e6a, 0x9c, 0xdb, 0x92, 0x27, 0x44, 0x90, 0x1f, 0x2c); 20 | 21 | // {5464fcae-c7f0-48eb-86da-d90626fb1e37} 22 | DEFINE_GUID(UnkGuid, 0x5464fcae, 0xc7f0, 0x48eb, 0x86, 0xda, 0xd9, 0x6, 0x26, 0xfb, 0x1e, 0x37); 23 | 24 | /* 25 | {7b444003-7f74-409b-b171-e8291b39d64e} 26 | {d549f8c9-2548-4194-8604-fbe30f07bbb1} 27 | {fffe1d66-5919-44ac-a2ab-86472ddbaf54} 28 | {1f7cb9cd-d63b-464a-bbd2-130857761f35} 29 | {d9fb15fc-b63f-4d37-8040-62fb3b059af7} 30 | {690049b7-1ef6-417f-b7a2-f7f538e85439} 31 | */ 32 | -------------------------------------------------------------------------------- /src/taskbarIcon.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | class TaskBarIcon 28 | { 29 | public: 30 | TaskBarIcon(); 31 | ~TaskBarIcon(); 32 | 33 | enum State { S_PROGRESS, S_NO_PROGRESS, S_WORKING, S_ERROR, S_PAUSED }; 34 | void SetState(State state, float param = 0.0f); 35 | 36 | protected: 37 | State last_state; 38 | }; 39 | 40 | -------------------------------------------------------------------------------- /src/Framework/StrUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include "StdHdr.h" 28 | #include "ObjString.h" 29 | 30 | String Format(const wchar_t * fmt, ...); 31 | 32 | String FormatNum(int64_t); 33 | String FormatTime(const FILETIME &); 34 | 35 | String FormatProgress(int64_t cb, int64_t total); 36 | String FormatSpeed(int64_t cb); 37 | String FormatValue(int64_t Value); 38 | -------------------------------------------------------------------------------- /src/Framework/FrameworkUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include "ObjString.h" 28 | 29 | typedef void (*ErrorHandler)(const wchar_t *); 30 | 31 | void FWError(const String &); 32 | void FWError(const wchar_t *); 33 | 34 | extern int WinNT, WinNT4, Win2K, WinXP; 35 | extern const String & LOC(const String &); 36 | extern ErrorHandler errorHandler; 37 | 38 | #define MAKEINT64(low, high) ((((int64_t)(high))<<32)|((int64_t)low)) 39 | -------------------------------------------------------------------------------- /FileCopyEx3.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 11.00 2 | # Visual Studio 2010 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FileCopyEx3", "FileCopyEx3.vcxproj", "{497E8E61-0A70-4F9D-86A2-890A1A3CB98A}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug Unicode|Win32 = Debug Unicode|Win32 8 | Debug Unicode|x64 = Debug Unicode|x64 9 | Release Unicode|Win32 = Release Unicode|Win32 10 | Release Unicode|x64 = Release Unicode|x64 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32 14 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32 15 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Debug Unicode|x64.ActiveCfg = Debug Unicode|x64 16 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Debug Unicode|x64.Build.0 = Debug Unicode|x64 17 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32 18 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Release Unicode|Win32.Build.0 = Release Unicode|Win32 19 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Release Unicode|x64.ActiveCfg = Release Unicode|x64 20 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Release Unicode|x64.Build.0 = Release Unicode|x64 21 | EndGlobalSection 22 | GlobalSection(SolutionProperties) = preSolution 23 | HideSolutionNode = FALSE 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /FileCopyEx3.vc10.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 11.00 2 | # Visual Studio 2010 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FileCopyEx3", "FileCopyEx3.vc10.vcxproj", "{497E8E61-0A70-4F9D-86A2-890A1A3CB98A}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug Unicode|Win32 = Debug Unicode|Win32 8 | Debug Unicode|x64 = Debug Unicode|x64 9 | Release Unicode|Win32 = Release Unicode|Win32 10 | Release Unicode|x64 = Release Unicode|x64 11 | EndGlobalSection 12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 13 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Debug Unicode|Win32.ActiveCfg = Debug Unicode|Win32 14 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Debug Unicode|Win32.Build.0 = Debug Unicode|Win32 15 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Debug Unicode|x64.ActiveCfg = Debug Unicode|x64 16 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Debug Unicode|x64.Build.0 = Debug Unicode|x64 17 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Release Unicode|Win32.ActiveCfg = Release Unicode|Win32 18 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Release Unicode|Win32.Build.0 = Release Unicode|Win32 19 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Release Unicode|x64.ActiveCfg = Release Unicode|x64 20 | {497E8E61-0A70-4F9D-86A2-890A1A3CB98A}.Release Unicode|x64.Build.0 = Release Unicode|x64 21 | EndGlobalSection 22 | GlobalSection(SolutionProperties) = preSolution 23 | HideSolutionNode = FALSE 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /src/Common.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include "Framework/ObjString.h" 28 | #include "Framework/FrameworkUtils.h" 29 | #include "SDK/plugin.hpp" 30 | #include "FarPlugin.h" 31 | 32 | extern HANDLE hInstance; 33 | 34 | BOOL __stdcall DllMain(HANDLE hInst, ULONG reason, LPVOID); 35 | 36 | const wchar_t * GetMsg(intptr_t MsgId); 37 | const String & LOC(const String & l); 38 | 39 | String GetFarProfilePath(); 40 | 41 | extern PluginStartupInfo Info; 42 | extern FarStandardFunctions FSF; 43 | extern FarPlugin * plugin; 44 | -------------------------------------------------------------------------------- /src/Framework/StdHdr.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #ifdef _WINXP 28 | #define _WIN2K 29 | #endif 30 | 31 | #ifdef _WIN2K 32 | #define _WINNT 33 | #endif 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | #define WIN32_LEAN_AND_MEAN 42 | #define VC_EXTRALEAN 43 | #ifndef NOMINMAX 44 | #define NOMINMAX 45 | #endif 46 | 47 | #define WIN32_NO_STATUS //exclude ntstatus.h macros from winnt.h 48 | #include 49 | #undef WIN32_NO_STATUS 50 | #ifndef _WINIOCTL_ 51 | #include 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /src/Framework/FrameworkUtils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | #include "StdHdr.h" 29 | #include "FrameworkUtils.h" 30 | 31 | int WinNT = 0, WinNT4 = 0, Win2K = 0, WinXP = 0; 32 | 33 | void FWError(const wchar_t * s) 34 | { 35 | if (errorHandler) 36 | { 37 | errorHandler(s); 38 | } 39 | else 40 | { 41 | MessageBox(0, s, L"FileCopyEx3 plugin error", MB_OK | MB_ICONSTOP | MB_SETFOREGROUND); 42 | DebugBreak(); 43 | } 44 | } 45 | 46 | void FWError(const String & s) 47 | { 48 | FWError(s.ptr()); 49 | } 50 | 51 | ErrorHandler errorHandler = nullptr; 52 | -------------------------------------------------------------------------------- /src/ui.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include "Framework/ObjString.h" 28 | 29 | intptr_t ShowMessage(const String &, const String &, uint32_t); 30 | intptr_t ShowMessageOK(const String &, const String &); 31 | intptr_t ShowMessageHelp(const String &, const String &, uint32_t, const String &); 32 | intptr_t ShowMessageEx(const String &, const String &, const String &, uint32_t); 33 | intptr_t ShowMessageExHelp(const String &, const String &, const String &, uint32_t, const String &); 34 | 35 | const int RES_RETRY = 1; 36 | const int RES_SKIP = 0; 37 | 38 | void Error(const String &, intptr_t code); 39 | void Error2(const String &, const String &, intptr_t code); 40 | intptr_t Error2RS(const String &, const String &, intptr_t code); 41 | 42 | String GetErrText(intptr_t code); 43 | 44 | String FormatWidth(const String &, intptr_t); 45 | String FormatWidthNoExt(const String &, intptr_t); 46 | String SplitWidth(const String &, intptr_t); 47 | -------------------------------------------------------------------------------- /make_dist.cmd: -------------------------------------------------------------------------------- 1 | REM @echo off 2 | REM @setlocal 3 | 4 | set PLUGINNAME=FileCopyEx3 5 | 6 | set FARVER=%1 7 | if "%FARVER%" equ "" set FARVER=Far3 8 | set PLUGINARCH=%2 9 | if "%PLUGINARCH%" equ "" set PLUGINARCH=x86 10 | 11 | :: Get plugin version from resource 12 | for /F "tokens=2,3 skip=2" %%i in (src\version.hpp) do set %%i=%%~j 13 | if "%PLUGIN_VERSION_TXT%" equ "" echo Undefined version & exit 1 14 | set PLUGINVER=%PLUGIN_VERSION_TXT% 15 | 16 | :: Package name 17 | set PKGNAME=%PLUGINNAME%-%PLUGINVER%_%FARVER%_%PLUGINARCH%.7z 18 | 19 | :: Create temp directory 20 | set PKGDIR=build\%PLUGINNAME%\%FARVER% 21 | set PKGDIRARCH=%PKGDIR%\%PLUGINARCH% 22 | if exist %PKGDIRARCH% rmdir /S /Q %PKGDIRARCH% 23 | 24 | :: Copy files 25 | if not exist %PKGDIR% ( mkdir %PKGDIR% > NUL ) 26 | mkdir %PKGDIRARCH% > NUL 27 | 28 | REM set PKGDIRARCH=%FARVER%_%PLUGINARCH%\Plugins\%PLUGINNAME% 29 | 30 | if exist *.lng copy *.lng %PKGDIRARCH% > NUL 31 | if exist *.hlf copy *.hlf %PKGDIRARCH% > NUL 32 | if exist *.md copy *.md %PKGDIRARCH% > NUL 33 | if exist LICENSE.txt copy LICENSE.txt %PKGDIRARCH% > NUL 34 | if exist changelog.txt copy changelog.txt %PKGDIRARCH% > NUL 35 | 36 | REM if not exist "%PKGDIRARCH%\doc" ( mkdir "%PKGDIRARCH%\doc" ) 37 | if not exist "%PKGDIRARCH%\resource" ( mkdir "%PKGDIRARCH%\resource" ) 38 | copy /Y data\*.hlf %PKGDIRARCH% 39 | copy /Y data\*.lng %PKGDIRARCH% 40 | copy /Y data\*.diz %PKGDIRARCH% 41 | copy /Y data\resource\*.* %PKGDIRARCH%\resource 42 | copy /Y ..\%PLUGINNAME%-build\%PLUGINNAME%.dll %PKGDIRARCH% 43 | 44 | :: Make archive 45 | set ARCHIVE_NAME=..\..\..\%PKGNAME% 46 | if exist %PKGDIRARCH%\%PLUGINNAME%.dll ( 47 | if exist "C:\Program Files\7-Zip\7z.exe" ( 48 | pushd %PKGDIRARCH% 49 | if exist %ARCHIVE_NAME% del %ARCHIVE_NAME% 50 | call "C:\Program Files\7-Zip\7z.exe" a -mx9 -t7z -r %ARCHIVE_NAME% * 51 | popd 52 | if errorlevel 1 echo Error creating archive & exit 1 /b 53 | echo Package %PKGNAME% created 54 | ) 55 | ) 56 | exit 0 /b 57 | -------------------------------------------------------------------------------- /src/Framework/FileNameStore.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include "ObjString.h" 30 | 31 | class FileName 32 | { 33 | public: 34 | enum Direction 35 | { 36 | levelPlus, 37 | levelMinus, 38 | levelSame, 39 | levelStar, 40 | }; 41 | 42 | FileName() : 43 | d(levelPlus), 44 | Name() 45 | {} 46 | FileName(const Direction _d, const String & _name) : 47 | d(_d), 48 | Name(_name) 49 | {} 50 | ~FileName() {} 51 | 52 | Direction getDirection() const { return d; } 53 | String getName() const { return Name; } 54 | 55 | private: 56 | Direction d; 57 | String Name; 58 | }; 59 | 60 | class FileNameStore 61 | { 62 | public: 63 | FileNameStore() {} 64 | ~FileNameStore() {} 65 | 66 | size_t AddRel(FileName::Direction _d, const String & _name) { items.push_back(FileName(_d, _name)); return items.size() - 1; } 67 | size_t Count() const { return items.size(); } 68 | const String GetNameByNum(size_t n) const { return items[n].getName(); } 69 | const FileName & operator[](size_t n) const { return items[n]; } 70 | FileName & operator[](size_t n) { return items[n]; } 71 | 72 | private: 73 | std::vector items; 74 | }; 75 | -------------------------------------------------------------------------------- /src/FarPlugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include "Framework/ObjString.h" 28 | #include "Framework/LocaleUtils.h" 29 | #include "Framework/Properties.h" 30 | #include "Framework/StringVector.h" 31 | #include "FarNode.h" 32 | #include "FarSettings.h" 33 | 34 | class FarPlugin 35 | { 36 | public: 37 | FarPlugin() : flags(0) {} 38 | ~FarPlugin(); 39 | void Create(); 40 | intptr_t Configure(const struct ConfigureInfo * Info); 41 | void OpenPlugin(const struct OpenInfo * OInfo); 42 | void InitLang(); 43 | void LoadOptions(); 44 | void SaveOptions(); 45 | void InitOptions(); 46 | void Config(); 47 | 48 | const Locale & getLocale() const { return locale; } 49 | PropertyMap & Options() { return options; } 50 | FarDialogList & Dialogs() { return dialogs; } 51 | FarSettings & Settings() { return settings; } 52 | 53 | const StringVector & Descs() const { return descs; } 54 | 55 | private: 56 | static String GetDLLPath(); 57 | void UpdateConfiguration(); 58 | 59 | FarDialogList dialogs; 60 | PropertyMap options; 61 | FarSettings settings; 62 | String CurLocaleFile; 63 | Locale locale; 64 | StringVector descs; 65 | 66 | int flags; 67 | 68 | void About(); 69 | static void KeyConfig(); 70 | void SoundConfig(); 71 | }; 72 | -------------------------------------------------------------------------------- /src/CopyProgress.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include "FarProgress.h" 28 | 29 | class CopyProgress : public FarProgress 30 | { 31 | public: 32 | CopyProgress(void); 33 | virtual ~CopyProgress(void); 34 | void Start(bool move); 35 | void Stop(); 36 | void ShowReadName(const String &); 37 | void ShowWriteName(const String &); 38 | 39 | void ShowProgress(int64_t read, int64_t write, int64_t total, 40 | int64_t readTime, int64_t writeTime, 41 | int64_t readN, int64_t writeN, 42 | int64_t totalN, bool parallel, 43 | int64_t FirstWrite, int64_t StartTime, size_t BufferSize); 44 | private: 45 | void RedrawWindowIfNeeded(); 46 | void RedrawWindow(); 47 | void DrawProgress(const String &, int, int64_t, int64_t, int64_t, int64_t, int64_t); 48 | 49 | void DrawName(const String &, int); 50 | 51 | void DrawTime(int64_t ReadBytes, int64_t WriteBytes, int64_t TotalBytes, 52 | int64_t ReadTime, int64_t WriteTime, 53 | int64_t ReadN, int64_t WriteN, int64_t TotalN, 54 | bool ParallelMode, int64_t FirstWriteTime, 55 | int64_t StartTime, size_t BufferSize); 56 | 57 | int64_t LastUpdate, LastUpdateRead, LastUpdateWrite, Interval; 58 | int64_t CopyLastUpdate, CopyInterval; 59 | 60 | int X1, Y1, X2, Y2; 61 | bool Move; 62 | }; 63 | -------------------------------------------------------------------------------- /src/Framework/FileNameStoreEnum.cpp: -------------------------------------------------------------------------------- 1 | #include "FileNameStoreEnum.h" 2 | #include "FrameworkUtils.h" 3 | 4 | String FileNameStoreEnum::GetNext() 5 | { 6 | if (cur >= store->Count()) 7 | { 8 | return L""; 9 | } 10 | 11 | const FileName & fn = (*store)[cur++]; 12 | 13 | switch (fn.getDirection()) 14 | { 15 | case FileName::levelPlus: 16 | { 17 | if (!curPath.empty()) 18 | { 19 | curPath += L"\\"; 20 | } 21 | curPath += fn.getName(); 22 | buffer = curPath; 23 | break; 24 | } 25 | 26 | case FileName::levelMinus: 27 | { 28 | buffer = curPath; 29 | curPath = curPath.substr(0, curPath.rfind('\\')); 30 | 31 | break; 32 | } 33 | 34 | case FileName::levelStar: 35 | { 36 | buffer = curPath; 37 | curPath.Clear(); 38 | break; 39 | } 40 | 41 | case FileName::levelSame: 42 | { 43 | buffer = curPath; 44 | if (!buffer.empty()) 45 | { 46 | buffer += L"\\"; 47 | } 48 | buffer += fn.getName(); 49 | } 50 | } 51 | 52 | return buffer; 53 | } 54 | 55 | void FileNameStoreEnum::Skip() 56 | { 57 | if (cur >= store->Count()) 58 | { 59 | return; 60 | } 61 | 62 | const FileName & fn = (*store)[cur++]; 63 | 64 | switch (fn.getDirection()) 65 | { 66 | case FileName::levelPlus: 67 | { 68 | if (!curPath.empty()) 69 | { 70 | curPath += L"\\"; 71 | } 72 | curPath += fn.getName(); 73 | break; 74 | } 75 | 76 | case FileName::levelMinus: 77 | { 78 | curPath = curPath.substr(0, curPath.rfind('\\')); 79 | break; 80 | } 81 | 82 | case FileName::levelStar: 83 | { 84 | curPath.Clear(); 85 | break; 86 | } 87 | } 88 | } 89 | 90 | void FileNameStoreEnum::ToFirst() 91 | { 92 | cur = 0; 93 | curPath.Clear(); 94 | buffer.Clear(); 95 | } 96 | 97 | String FileNameStoreEnum::GetByNum(size_t n) 98 | { 99 | if (cur > n + 1) 100 | { 101 | FWError(L"FileNameStoreEnum::GetByNum - assertion failure"); 102 | return L""; 103 | } 104 | 105 | if (cur == n + 1) 106 | { 107 | return buffer; 108 | } 109 | else 110 | { 111 | while (cur < n) 112 | Skip(); 113 | return GetNext(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/taskbarIcon.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include "Framework/StdHdr.h" 26 | #include "taskbarIcon.h" 27 | #include "Common.h" 28 | #include "guid.hpp" 29 | 30 | TaskBarIcon::TaskBarIcon() : last_state(S_NO_PROGRESS) 31 | { 32 | } 33 | 34 | TaskBarIcon::~TaskBarIcon() 35 | { 36 | if (last_state != S_NO_PROGRESS) 37 | SetState(S_NO_PROGRESS); 38 | } 39 | void TaskBarIcon::SetState(State state, float param) 40 | { 41 | switch (state) 42 | { 43 | case S_PROGRESS: 44 | if (param > 1.0f) 45 | { 46 | param = 1.0f; 47 | } 48 | if (param < 0.0f) 49 | { 50 | param = 0.0f; 51 | } 52 | ProgressValue pv; 53 | pv.Completed = (int64_t)(param * 100.0f); 54 | pv.Total = 100; 55 | Info.AdvControl(&MainGuid, ACTL_SETPROGRESSSTATE, TBPS_NORMAL, nullptr); 56 | Info.AdvControl(&MainGuid, ACTL_SETPROGRESSVALUE, 0, &pv); 57 | break; 58 | 59 | case S_NO_PROGRESS: 60 | Info.AdvControl(&MainGuid, ACTL_SETPROGRESSSTATE, TBPS_NOPROGRESS, nullptr); 61 | break; 62 | case S_WORKING: 63 | Info.AdvControl(&MainGuid, ACTL_SETPROGRESSSTATE, TBPS_INDETERMINATE, nullptr); 64 | break; 65 | case S_ERROR: 66 | Info.AdvControl(&MainGuid, ACTL_SETPROGRESSSTATE, TBPS_ERROR, nullptr); 67 | break; 68 | case S_PAUSED: 69 | Info.AdvControl(&MainGuid, ACTL_SETPROGRESSSTATE, TBPS_PAUSED, nullptr); 70 | break; 71 | } 72 | last_state = state; 73 | } 74 | -------------------------------------------------------------------------------- /src/FarProgress.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include "FarPlugin.h" 28 | #include "taskbarIcon.h" 29 | 30 | const int WIN_NONE = 0; 31 | const int WIN_MESSAGE = 1; 32 | const int WIN_PROGRESS = 2; 33 | const int WIN_SCAN_PROGRESS = 3; 34 | 35 | class FarProgress 36 | { 37 | public: 38 | FarProgress(void); 39 | virtual ~FarProgress(void); 40 | void ShowMessage(const String &); 41 | void ShowProgress(const String &); 42 | void ShowScanProgress(const String & msg); 43 | void SetScanProgressInfo(int64_t NumberOfFiles, int64_t TotalSize); 44 | void Hide(); 45 | void SetPercent(float); 46 | void SetNeedToRedraw(bool Value); 47 | 48 | bool InverseBars; 49 | protected: 50 | FarColor clrFrame, clrTitle, clrBar, clrText, clrLabel; 51 | int ProgX1, ProgX2, ProgY, WinType; 52 | HANDLE hScreen; 53 | static void DrawWindow(int, int, int, int, const String &); 54 | static void GetConSize(int &, int &); 55 | void DrawProgress(int, int, int, float); 56 | static void Text(intptr_t, intptr_t, FarColor *, const String &); 57 | static void SetTitle(const String &); 58 | void SetTitle2(const String &) const; 59 | static String GetTitle(); 60 | String TitleBuf, ProgTitle; 61 | void DrawScanProgress(int x1, int x2, int y, int64_t NumberOfFiles, int64_t TotalSize); 62 | int64_t LastUpdate; 63 | bool NeedToRedraw; 64 | 65 | TaskBarIcon taskbarIcon; 66 | 67 | private: 68 | void RedrawWindowIfNeeded(); 69 | void RedrawWindow(); 70 | }; 71 | -------------------------------------------------------------------------------- /src/Framework/Node.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include "Properties.h" 28 | #include "StringVector.h" 29 | 30 | class Payload; 31 | 32 | class Node 33 | { 34 | public: 35 | Node(); 36 | virtual ~Node(); 37 | 38 | virtual void init(Payload * _payload, Node * _parent); 39 | 40 | Node & operator[](size_t i) { return child(i); } 41 | Node & operator[](const String & v) { return child(v); } 42 | Property & operator()(const String & name); 43 | 44 | Payload & getPayload() const; 45 | Node * getParent() { return parent; } 46 | const String getName() const; 47 | //const String getType() const; 48 | 49 | int LoadFrom(FILE *); 50 | bool Load(const String &); 51 | void ReloadProperties() const; 52 | void ReloadPropertiesRecursive(); 53 | 54 | //void init(const String &name, const String &type, ObjectClass* cl, Object* parent); 55 | 56 | protected: 57 | void ClearChilds(); 58 | Node & child(size_t i) { return *childs[i]; } 59 | Node & child(const String & v); 60 | 61 | virtual void AfterLoad() {} 62 | virtual void BeforeLoad() {} 63 | 64 | std::vector childs; 65 | Payload * payload; 66 | Node * parent; 67 | 68 | private: 69 | size_t LoadFromList(StringParent &, size_t start = 0); 70 | //void SaveToList(StringVector&, int clear=1, int level=0); 71 | 72 | private: 73 | Node(const Node &); 74 | Node & operator = (const Node &); 75 | }; 76 | 77 | #define DEFINE_NODE_CLASS(type) \ 78 | static Node* create() { return new type(); } 79 | -------------------------------------------------------------------------------- /src/FarMenu.cpp: -------------------------------------------------------------------------------- 1 | #include "FarMenu.h" 2 | 3 | #include "Common.h" 4 | #include "guid.hpp" 5 | 6 | FarMenu::FarMenu() : 7 | Flags(0), Selection(0) 8 | { 9 | } 10 | 11 | FarMenu::~FarMenu() 12 | { 13 | for (size_t Index = 0; Index < items.size(); ++Index) 14 | { 15 | delete[] items[Index].Text; 16 | } 17 | } 18 | 19 | void FarMenu::SetItemText(FarMenuItem * item, const String & text) 20 | { 21 | size_t len = text.len() + 1; 22 | delete[] item->Text; 23 | wchar_t * t = new wchar_t[len]; 24 | text.copyTo(t, len); 25 | item->Text = t; 26 | } 27 | 28 | void FarMenu::AddLine(const String & line) 29 | { 30 | FarMenuItem item; 31 | ::ZeroMemory(&item, sizeof(item)); 32 | item.Flags = 0; 33 | if (Selection == items.size()) 34 | { 35 | item.Flags = MIF_SELECTED; 36 | } 37 | SetItemText(&item, line); 38 | items.push_back(item); 39 | } 40 | 41 | void FarMenu::AddLineCheck(const String & line, int check) 42 | { 43 | FarMenuItem item; 44 | ::ZeroMemory(&item, sizeof(item)); 45 | item.Flags = 0; 46 | if (check) 47 | { 48 | item.Flags |= MIF_CHECKED; 49 | } 50 | if (Selection == items.size()) 51 | { 52 | item.Flags = MIF_SELECTED; 53 | } 54 | SetItemText(&item, line); 55 | items.push_back(item); 56 | } 57 | 58 | void FarMenu::AddSep() 59 | { 60 | FarMenuItem item; 61 | ::ZeroMemory(&item, sizeof(item)); 62 | item.Flags = MIF_SEPARATOR; 63 | SetItemText(&item, String()); 64 | items.push_back(item); 65 | } 66 | 67 | intptr_t FarMenu::Execute() 68 | { 69 | return Info.Menu(&MainGuid, &MenuGuid, -1, -1, 0, FMENU_WRAPMODE, Title.c_str(), nullptr, HelpTopic.c_str(), nullptr, nullptr, items.data(), items.size()); 70 | } 71 | 72 | void FarMenu::SetBottom(const String & v) 73 | { 74 | Bottom = v; 75 | } 76 | 77 | void FarMenu::SetFlags(DWORD f) 78 | { 79 | Flags = f; 80 | } 81 | 82 | void FarMenu::SetHelpTopic(const String & v) 83 | { 84 | HelpTopic = v; 85 | } 86 | 87 | void FarMenu::SetSelection(size_t n) 88 | { 89 | Selection = n; 90 | if (Selection < items.size()) 91 | { 92 | for (size_t I = 0; I < items.size(); I++) 93 | { 94 | FarMenuItem & item = items[I]; 95 | if (I != Selection) 96 | item.Flags &= ~MIF_SELECTED; 97 | else 98 | item.Flags |= MIF_SELECTED; 99 | } 100 | } 101 | } 102 | 103 | void FarMenu::SetTitle(const String & v) 104 | { 105 | Title = v; 106 | } 107 | -------------------------------------------------------------------------------- /src/Framework/Properties.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | #include "ObjString.h" 31 | 32 | class Property 33 | { 34 | enum Type { vtUnknown, vtInt, vtFloat, vtString }; 35 | public: 36 | Property() : type(vtUnknown), vInt(0), vFloat(0.0) {} 37 | Property(const Property & other); 38 | Property(int); 39 | Property(float); 40 | Property(const String &); 41 | 42 | Property & operator = (const Property & p); 43 | 44 | operator int() const; 45 | operator int64_t() const; 46 | operator bool() const; 47 | operator float() const; 48 | operator const String() const; 49 | 50 | bool operator==(int v) const { return v == (int) * this; } 51 | bool operator==(bool v) const { return v == (bool) * this; } 52 | bool operator==(float v) const { return v == (float) * this; } 53 | bool operator==(const String & v) const { return v.cmp(this->operator const String()) == 0; } 54 | bool operator==(const Property & v) const; 55 | 56 | bool operator!=(int v) const { return !operator==(v); } 57 | bool operator!=(bool v) const { return !operator==(v); } 58 | bool operator!=(float v) const { return !operator==(v); } 59 | bool operator!=(const String & v) const { return !operator==(v); } 60 | bool operator!=(const Property & v) const { return !operator==(v); } 61 | 62 | bool operator!() const { return !(bool) * this; } 63 | 64 | protected: 65 | Type type; 66 | int64_t vInt; 67 | float vFloat; 68 | String vStr; 69 | }; 70 | 71 | typedef std::map PropertyMap; 72 | 73 | -------------------------------------------------------------------------------- /src/common.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include "Framework/StdHdr.h" 26 | #include "Framework/ObjString.h" 27 | #include "Common.h" 28 | 29 | HANDLE hInstance; 30 | 31 | BOOL __stdcall DllMain(HANDLE hInst, ULONG reason, LPVOID) 32 | { 33 | hInstance = hInst; 34 | if (reason == DLL_PROCESS_ATTACH) 35 | { 36 | _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); 37 | OSVERSIONINFO osv; 38 | osv.dwOSVersionInfoSize = sizeof(osv); 39 | ::GetVersionEx(&osv); 40 | WinNT = osv.dwPlatformId == VER_PLATFORM_WIN32_NT; 41 | WinNT4 = WinNT && osv.dwMajorVersion == 4; 42 | Win2K = WinNT && osv.dwMajorVersion >= 5; 43 | WinXP = Win2K && (osv.dwMajorVersion > 5 || osv.dwMinorVersion >= 1); 44 | } 45 | return TRUE; 46 | } 47 | 48 | const String & LOC(const String & l) 49 | { 50 | try 51 | { 52 | return plugin->getLocale().at(l); 53 | } 54 | catch(const std::out_of_range &) 55 | { 56 | return l; 57 | } 58 | } 59 | 60 | static String getEnv(const String & name) 61 | { 62 | wchar_t * buf; 63 | size_t len; 64 | if (_wdupenv_s(&buf, &len, name.c_str()) == 0) 65 | { 66 | String v(buf); 67 | free(buf); 68 | return v; 69 | } 70 | return L""; 71 | } 72 | 73 | String GetFarProfilePath() 74 | { 75 | static String base; 76 | 77 | if (base.empty()) 78 | { 79 | base = getEnv(L"FARPROFILE"); 80 | } 81 | if (base.empty()) 82 | { 83 | base = getEnv(L"APPDATA"); 84 | if (!base.empty()) 85 | { 86 | base += L"\\Far Manager\\Profile"; 87 | } 88 | } 89 | return base; 90 | } 91 | 92 | -------------------------------------------------------------------------------- /src/EngineTools.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include "Framework/StdHdr.h" 28 | #include "Framework/ObjString.h" 29 | 30 | #define msgw() 50 31 | 32 | const int eeShowReopen = 1; 33 | const int eeShowKeepFiles = 2; 34 | const int eeYesNo = 4; 35 | const int eeRetrySkipAbort = 8; 36 | const int eerReopen = 16; 37 | const int eerKeepFiles = 32; 38 | const int eeOneLine = 64; 39 | const int eeAutoSkipAll = 128; 40 | const int eeAutoRetry = 256; 41 | 42 | const int RES_ABORT = 101; 43 | const int RES_YES = 0; 44 | const int RES_NO = -1; 45 | 46 | const int errfSkipAll = 1024; 47 | const int errfKeepFiles = 2048; 48 | 49 | void * Alloc(size_t size); 50 | void Free(void * ptr); 51 | void FCompress(HANDLE handle, uint32_t flags); 52 | int FGetCompression(HANDLE handle); 53 | void FEncrypt(const String & fn, uint32_t flags); 54 | void FEncrypt(HANDLE handle, uint32_t flags); 55 | void FCopyACL(const String & src, const String & dst); 56 | HANDLE FOpen(const String & fn, DWORD mode, DWORD attr); 57 | int64_t FSeek(HANDLE h, int64_t pos, int method); 58 | int64_t FTell(HANDLE h); 59 | bool IsFAT(const String & Path); 60 | 61 | void SetFileSizeAndTime2(const String & fn, int64_t size, 62 | const FILETIME * creationTime, const FILETIME * lastAccessTime, 63 | const FILETIME * lastWriteTime); 64 | void SetFileSizeAndTime2(HANDLE h, int64_t size, 65 | const FILETIME * creationTime, const FILETIME * lastAccessTime, 66 | const FILETIME * lastWriteTime); 67 | void SetFileTime2(const String & fn, const FILETIME * creationTime, 68 | const FILETIME * lastAccessTime, const FILETIME * lastWriteTime); 69 | void SetFileTime2(HANDLE h, const FILETIME * creationTime, 70 | const FILETIME * lastAccessTime, const FILETIME * lastWriteTime); 71 | size_t FRead(HANDLE h, void * buf, size_t size); 72 | size_t FWrite(HANDLE h, const void * buf, size_t size); 73 | size_t GetSectorSize(const String & path); 74 | -------------------------------------------------------------------------------- /src/Framework/FileUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include "StdHdr.h" 28 | #include "ObjString.h" 29 | 30 | const int MAX_FILENAME = 4096; 31 | const int DEFAULT_SECTOR_SIZE = 4096; 32 | 33 | const int OPEN_BUF = 128; 34 | const int OPEN_READ = 1; 35 | const int OPEN_CREATE = 2; 36 | const int OPEN_APPEND = 4; 37 | const int OPEN_WRITE = 8; 38 | const int OPEN_WRITE_BUF = OPEN_WRITE | OPEN_BUF; 39 | 40 | #define LO32(i) (int)(i & 0xFFFFFFFF) 41 | #define HI32(i) (int)(i >> 32) 42 | 43 | String GetLongFileName(const String & FileName); 44 | String ExtractFileName(const String &); 45 | String ExtractFilePath(const String &); 46 | String ExtractFileExt(const String &); 47 | String CutEndSlash(const String &); 48 | String AddEndSlash(const String &); 49 | String ChangeFileExt(const String &, const String &); 50 | 51 | const int gslExpandSubst = 1; 52 | const int gslExpandNetMappings = 2; 53 | const int gslExpandReparsePoints = 4; 54 | const int gslExpandMountPoints = 8; 55 | 56 | const int rfnNoNetExpand = 1; 57 | 58 | extern HANDLE FOpen(const String & fn, DWORD mode, DWORD attr); 59 | void FClose(HANDLE h); 60 | bool FDelete(const String & fn); 61 | 62 | String GetFileRoot(const String &); 63 | String GetRealFileName(const String &, uint32_t flags = 0); 64 | bool GetSymLink(const String & dir, String & res, uint32_t flags); 65 | String GetFileNameRoot(const String &); 66 | String ExpandEnv(const String &); 67 | 68 | String ApplyFileMask(const String & name, const String & mask); 69 | String ApplyFileMaskPath(const String & name, const String & mask); 70 | 71 | bool FileExists(const String & name); 72 | bool FMoveFile(const String & src, const String & dst, bool Replace); 73 | void ForceDirectories(const String & s); 74 | 75 | int64_t FileSize(HANDLE h); 76 | int64_t FileSize(const String & fn); 77 | 78 | String TempName(); 79 | String TempPath(); 80 | String TempPathName(); 81 | 82 | void Out(const String & s); 83 | 84 | bool GetPrimaryVolumeMountPoint(const String & VolumeMountPointForPath, String & PrimaryVolumeMountPoint); 85 | 86 | -------------------------------------------------------------------------------- /src/FarMacro.cpp: -------------------------------------------------------------------------------- 1 | #if !defined(_MSC_VER) 2 | #include 3 | #endif 4 | #include "FarMacro.h" 5 | 6 | #include "Framework/StringVector.h" 7 | #include "Framework/FileUtils.h" 8 | #include "Common.h" 9 | #include "version.hpp" 10 | #include "guid.hpp" 11 | 12 | void Bind(const String & key, const String & code, const String & desc, int id) 13 | { 14 | String DirName = GetMacrosPath(PLUGIN_BUILD); 15 | if (DirName.empty()) 16 | { 17 | return; // Cannot find correct path 18 | } 19 | if (!FileExists(DirName)) 20 | { 21 | ForceDirectories(DirName); 22 | } 23 | String fname = GetMacroFileName(key); 24 | StringVector v; 25 | v.AddString(String(L"Macro {")); 26 | v.AddString(String(L" area=\"Shell\";")); 27 | v.AddString(String(L" key=\"") + key + L"\";"); 28 | v.AddString(String(L" flags=\"NoPluginPanels|NoPluginPPanels|NoSendKeysToPlugins\";")); 29 | v.AddString(String(L" priority=0;")); 30 | v.AddString(String(L" description=\"") + desc + L"\";"); 31 | v.AddString(String(L" action = function()")); 32 | v.AddString(String(L" ") + code); 33 | v.AddString(String(L" end;")); 34 | v.AddString(String(L"}")); 35 | 36 | v.saveToFile(DirName + fname); 37 | 38 | Info.MacroControl(&MainGuid, MCTL_LOADALL, 0, nullptr); 39 | 40 | FarSettings & settings = plugin->Settings(); 41 | settings.set(key, L"true"); 42 | PropertyMap & options = plugin->Options(); 43 | options[key] = Property(L"true"); 44 | } 45 | 46 | int Bound(const String & key) 47 | { 48 | FarSettings & settings = plugin->Settings(); 49 | String value; 50 | return settings.get(key, value) && !value.IsEmpty(); 51 | } 52 | 53 | void Unbind(const String & key) 54 | { 55 | String MacrosPath = GetMacrosPath(PLUGIN_BUILD); 56 | if (FileExists(MacrosPath)) 57 | { 58 | RemoveMacroFile(MacrosPath, key); 59 | } 60 | 61 | FarSettings & settings = plugin->Settings(); 62 | settings.set(key, L""); 63 | PropertyMap & options = plugin->Options(); 64 | options[key] = Property(L""); 65 | //Info.MacroControl(&MainGuid, MCTL_DELMACRO, 0, id); 66 | } 67 | 68 | String GetMacrosPath(uintptr_t PluginBuildNumber) 69 | { 70 | String ProfilePath = GetFarProfilePath(); 71 | if (ProfilePath.empty()) 72 | { 73 | return L""; // Cannot find correct path 74 | } 75 | String DirName; 76 | if (PluginBuildNumber <= 20) 77 | { 78 | DirName = AddEndSlash(AddEndSlash(ProfilePath) + L"Macros\\internal"); 79 | } 80 | else 81 | { 82 | DirName = AddEndSlash(AddEndSlash(ProfilePath) + L"Macros\\scripts"); 83 | } 84 | return DirName; 85 | } 86 | 87 | String GetMacroFileName(const String & Key) 88 | { 89 | return String(L"Shell_") + Key + L".lua"; 90 | } 91 | 92 | void RemoveMacroFile(const String & MacrosPath, const String & Key) 93 | { 94 | String MacroFileName = GetMacroFileName(Key); 95 | String FullMacroFileName = AddEndSlash(MacrosPath) + MacroFileName; 96 | if (FileExists(FullMacroFileName)) 97 | { 98 | // check if macros are created by plugin 99 | StringVector v; 100 | v.loadFromFile(FullMacroFileName); 101 | if (v.FindAny(L"FileCopyEx3") != -1) 102 | { 103 | FDelete(FullMacroFileName); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/FarNode.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include "Framework/Node.h" 28 | #include "Framework/CastNode.h" 29 | #include "Framework/ObjectManager.h" 30 | 31 | #include "SDK/plugin.hpp" 32 | 33 | class FarDlgPayload; 34 | class FarDialogClass; 35 | 36 | struct RetCode 37 | { 38 | intptr_t itemNo; 39 | intptr_t retCode; 40 | }; 41 | 42 | class FarDialog; 43 | class ValueList; 44 | 45 | class FarDlgNode : public CastNode 46 | { 47 | public: 48 | FarDlgNode(); 49 | virtual ~FarDlgNode(void); 50 | 51 | DEFINE_NODE_CLASS(FarDlgNode); 52 | 53 | virtual void InitItem(FarDialogItem & item); 54 | virtual void RetrieveProperties(HANDLE dlg); 55 | virtual void BeforeAdd(FarDialogItem & item); 56 | virtual void LoadState(PropertyMap & state); 57 | virtual void SaveState(PropertyMap & state); 58 | 59 | virtual void DefSize(intptr_t &, intptr_t &, intptr_t &); 60 | 61 | virtual int IsContainer() { return 0; } 62 | virtual void AddToItems(std::vector& Items, std::vector& RetCodes, intptr_t curX, intptr_t curY, intptr_t curW); 63 | virtual void ClearDialogItem(); 64 | virtual FarDlgNode * FindChild(const String &); 65 | 66 | protected: 67 | virtual void BeforeLoad(); 68 | }; 69 | 70 | class FarDlgContainer : public FarDlgNode 71 | { 72 | public: 73 | virtual ~FarDlgContainer() {} 74 | DEFINE_NODE_CLASS(FarDlgContainer); 75 | 76 | virtual int IsContainer() { return 1; } 77 | 78 | virtual void LoadState(PropertyMap & state); 79 | virtual void SaveState(PropertyMap & state); 80 | protected: 81 | virtual void AddToItems(std::vector&, std::vector&, intptr_t, intptr_t, intptr_t); 82 | 83 | virtual void DefSize(intptr_t &, intptr_t &, intptr_t &); 84 | virtual void ClearDialogItems(std::vector&); 85 | virtual FarDlgNode * FindChild(const String &); 86 | 87 | virtual void RetrieveProperties(HANDLE dlg); 88 | }; 89 | 90 | class FarDialog : public FarDlgContainer 91 | { 92 | public: 93 | FarDialog(); 94 | virtual ~FarDialog(); 95 | 96 | DEFINE_NODE_CLASS(FarDialog); 97 | 98 | intptr_t Execute(); 99 | void ResetControls(); 100 | 101 | FarDlgNode & operator[](const String &); 102 | 103 | protected: 104 | void BeforeLoad(); 105 | }; 106 | 107 | class FarDialogList : public CastNode 108 | { 109 | }; 110 | -------------------------------------------------------------------------------- /src/FileCopyEx.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "SDK/plugin.hpp" 4 | #include "Common.h" 5 | #include "version.hpp" 6 | #include "FarPlugin.h" 7 | #include "FarPayload.h" 8 | #include "guid.hpp" 9 | 10 | PluginStartupInfo Info; 11 | FarStandardFunctions FSF; 12 | 13 | FarPlugin * plugin = nullptr; 14 | 15 | /* 16 | Функция GetMsg возвращает строку сообщения из языкового файла. 17 | А это надстройка над Info.GetMsg для сокращения кода :-) 18 | */ 19 | const wchar_t * GetMsg(intptr_t MsgId) 20 | { 21 | return Info.GetMsg(&MainGuid, MsgId); 22 | } 23 | 24 | static void FarErrorHandler(const wchar_t * s) 25 | { 26 | const wchar_t * items[] = { L"Framework Error", s, L"OK", L"Debug" }; 27 | if (Info.Message(&MainGuid, &MainGuid, FMSG_WARNING, nullptr, items, 4, 2) == 1) 28 | { 29 | DebugBreak(); 30 | } 31 | } 32 | 33 | /* 34 | Far Manager вызывает функцию GetGlobalInfoW в первую очередь, для получения основной информации о плагине. 35 | Функция вызывается один раз. 36 | */ 37 | void WINAPI GetGlobalInfoW(struct GlobalInfo * Info) 38 | { 39 | Info->StructSize = sizeof(GlobalInfo); 40 | Info->MinFarVersion = PLUGIN_MIN_FAR_VERSION; 41 | Info->Version = PLUGIN_VERSION; 42 | Info->Guid = MainGuid; 43 | Info->Title = PLUGIN_TITLE; 44 | Info->Description = PLUGIN_DESC; 45 | Info->Author = PLUGIN_AUTHOR; 46 | } 47 | 48 | /* 49 | Функция SetStartupInfoW вызывается один раз, после загрузки DLL-модуля в память. 50 | Far Manager передаёт плагину информацию, необходимую для дальнейшей работы. 51 | */ 52 | void WINAPI SetStartupInfoW(const struct PluginStartupInfo * psi) 53 | { 54 | if (psi->StructSize >= sizeof(PluginStartupInfo)) 55 | { 56 | Info = *psi; 57 | FSF = *Info.FSF; 58 | if (!plugin) 59 | { 60 | errorHandler = FarErrorHandler; 61 | InitObjMgr(); 62 | plugin = new FarPlugin(); 63 | plugin->Create(); 64 | } 65 | } 66 | } 67 | 68 | /* 69 | Функция GetPluginInfoW вызывается Far Manager для получения дополнительной информации о плагине. 70 | */ 71 | static const wchar_t * pluginMenuStrings[1] = { L"File copy extended" }; 72 | static const wchar_t * configMenuStrings[1] = { L"File copy extended" }; 73 | 74 | void WINAPI GetPluginInfoW(struct PluginInfo * Info) 75 | { 76 | Info->StructSize = sizeof(*Info); 77 | 78 | Info->PluginMenu.Guids = &MenuGuid; 79 | Info->PluginMenu.Strings = pluginMenuStrings; 80 | Info->PluginMenu.Count = ARRAYSIZE(pluginMenuStrings); 81 | 82 | Info->PluginConfig.Guids = &ConfigGuid; 83 | Info->PluginConfig.Strings = configMenuStrings; 84 | Info->PluginConfig.Count = ARRAYSIZE(configMenuStrings); 85 | 86 | plugin->InitLang(); 87 | } 88 | 89 | /* 90 | Функция ConfigureW вызывается Far Manager, когда пользователь выбрал в меню "Параметры внешних модулей" пункт, добавленный туда данным плагином. 91 | */ 92 | intptr_t WINAPI ConfigureW(const struct ConfigureInfo * Info) 93 | { 94 | return plugin->Configure(Info); 95 | } 96 | 97 | /* 98 | Функция OpenW вызывается при создании новой копии плагина. 99 | */ 100 | HANDLE WINAPI OpenW(const struct OpenInfo * OInfo) 101 | { 102 | plugin->InitLang(); 103 | plugin->OpenPlugin(OInfo); 104 | plugin->SaveOptions(); 105 | if (OInfo->OpenFrom == OPEN_FROMMACRO) 106 | { 107 | return reinterpret_cast(1); 108 | } 109 | else 110 | { 111 | return nullptr; 112 | } 113 | } 114 | 115 | void WINAPI ExitFARW(const struct ExitInfo * Info) 116 | { 117 | delete plugin; 118 | DoneObjMgr(); 119 | } 120 | -------------------------------------------------------------------------------- /src/tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include "SDK/plugin.hpp" 28 | #include "framework/ObjString.h" 29 | 30 | const int ATTR_OFF = 0; 31 | const int ATTR_ON = 1; 32 | const int ATTR_INHERIT = 2; 33 | 34 | enum TOverwriteMode 35 | { 36 | OM_CANCEL = -1, 37 | OM_PROMPT = 0, 38 | OM_OVERWRITE = 1, 39 | OM_SKIP = 2, 40 | OM_APPEND = 3, 41 | OM_RENAME = 4, 42 | OM_RESUME = 5, 43 | }; 44 | 45 | const int FLG_COPIED = 1; 46 | const int FLG_DELETED = 2; 47 | const int FLG_SKIPPED = 4; 48 | const int FLG_ERROR = 8; 49 | const int FLG_SKIPNEWER = 16; 50 | const int FLG_NEEDDEL = 32; 51 | const int FLG_DECSIZE = 64; 52 | const int FLG_DIR_PRE = 256; 53 | const int FLG_DIR_POST = 512; 54 | const int FLG_DESCFILE = 1024; 55 | const int FLG_DESC_INVERSE = 2048; 56 | const int FLG_DIR_NOREMOVE = 4096; 57 | const int FLG_DIR_FORCE = 8192; 58 | const int FLG_KEEPFILE = 16384; 59 | const int FLG_BUFFERED = 32768; 60 | const int FLG_TOP_DIR = 65536; 61 | 62 | const int AF_CLEAR_RO = 2; 63 | const int AF_STREAM = 4; 64 | const int AF_TOPLEVEL = 8; 65 | const int AF_DESCFILE = 16; 66 | const int AF_DESC_INVERSE = 32; 67 | 68 | const int VF_COMPRESSION = 1; 69 | const int VF_ENCRYPTION = 2; 70 | const int VF_RIGHTS = 4; 71 | const int VF_FAT = 8; 72 | const int VF_STREAMS = 16; 73 | const int VF_READONLY = 32; 74 | const int VF_UNICODE = 64; 75 | const int VF_CDROM = 128; 76 | 77 | template 78 | inline const T & Min(const T & a, const T & b) { return a < b ? a : b; } 79 | 80 | template 81 | inline const T & Max(const T & a, const T & b) { return a > b ? a : b; } 82 | 83 | bool ExistsN(const String & fn, intptr_t n); 84 | String DupName(const String & src, intptr_t n); 85 | bool RmDir(const String & fn); 86 | bool Newer(const FILETIME & ft1, const FILETIME & ft2); 87 | bool Newer(const String & fn1, const FILETIME & ft2); 88 | 89 | uint32_t VolFlags(const String & Path); 90 | intptr_t CheckParallel(const String & srcpath, const String & dstpath); 91 | 92 | String GetSymLink(const String & dir); 93 | 94 | void Beep(int); 95 | 96 | void DebugLog(const wchar_t * DebugMsg, ...); 97 | 98 | String ConvertPath(enum CONVERTPATHMODES mode, const String & src); 99 | 100 | inline int64_t GetTime() 101 | { 102 | LARGE_INTEGER res; 103 | ::QueryPerformanceCounter(&res); 104 | return res.QuadPart; 105 | } 106 | 107 | inline int64_t TicksPerSec() 108 | { 109 | LARGE_INTEGER res; 110 | ::QueryPerformanceFrequency(&res); 111 | return res.QuadPart; 112 | } 113 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | So, this plugin is designed to implement various perverted fantasies of copying, each of which will accelerate the process for 5% :). At the moment, it implements the basic capabilities, which sometimes quite lacking in standard copyists. (C) 2 | 3 | Main features: 4 | Buffering copy multiple files at once. When we copy small files, instead of individually to read and write each file, we can read a couple of them and then write this files. This reduces the number of movements of heads from source to destination, which is strongly affected when copying between two sections of a hard drive. The idea is taken from DOS Navigator. 5 | Minimize the fragmentation of copying. When copying large files is large blocks to reduce the number of reallocations of disk space with an increase in file size. 6 | Optimization for caching. Block sizes for reading and writing are chosen so that the system can cache the data in the most optimal way to copy. 7 | Parallel copying. Reading and writing simultaneously. This applies when copying data between different physical media, like two hard disks or CD to the hard drive. Maximum performance gain (2 times) can be reached if the reading speed of the original media is equal to the writing speed to destination. 8 | Support for NTFS: compression and encryption. It is possible to specify whether the copied files to the new location are compressed and encrypted or not. (Encryption support is available only in Windows 2000). The plugin also copies permissions and NTFS streams. 9 | Improved modes overwriting existing files, including appending, automatic and manual renaming. The idea is taken from DOS Navigator. 10 | 11 | --- 12 | 13 | Итак, этот плагин создан для того, чтобы воплотить в жизнь всевозможные извращенные фантазии на тему копирования, каждая из которых ускорит процесс на 5% :). На данный момент в нем реализованы основные возможности, которых иногда довольно сильно не хватало в стандартных копировщиках. (Ц) 14 | 15 | Основные возможности: 16 | Буферизация копирования для нескольких файлов сразу. При копировании мелких файлов вместо того, чтобы каждый по отдельности читать и записывать, можно прочитать их несколько штук, а затем несколько штук записать. Это уменьшает количество перемещений головок от источника к назначению, которое сильно сказывается при копировании между двумя разделами одного винчестера. Идея сперта из ДОС Навигатора. 17 | Минимизация фрагментации при копировании. При копировании больших файлов ведется большими блоками, чтобы уменьшить количество перераспределений места на диске при увеличении размера файла. 18 | Оптимизация под кэширование. Размеры блоков для чтения и записи подобраны так, чтобы система могла кэшировать данные наиболее оптимальным для копирования способом. 19 | Параллельное копирование. И чтение, и запись происходят одновременно. Это применяется при копировании данных между разными физическими носителями, например двумя винчестерами, или с CD на винчестер. Максимум прироста производительности (в 2 раза) будет, если скорость чтения исходного носителя равна скорости записи назначения. 20 | Поддержка NTFS: сжатие и шифрование. Есть возможность указать, будут ли скопированные файлы на новом месте сжаты и зашифрованы, или нет. (Поддержка шифрования есть только в Windows 2000). Плагин также копирует права доступа и NTFS потоки. 21 | Улучшенные режимы перезаписи существующих файлов, включая дописывание, автоматическое и ручное переименование. Идея сперта из ДОС Навигатора. 22 | 23 | --- 24 | 25 | Copyright (C) 2004 - 2014 26 | Idea & core: Max Antipin 27 | Coding: Serge Cheperis aka craZZy 28 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 29 | Special thanks to Vitaliy Tsubin 30 | Far 2 (32 & 64 bit) full unicode version by djdron 31 | Far 3 (32 & 64 bit) Ruslan Petrenko (ruslanp@ruslanp.com), Michael Lukashov (michael.lukashov@gmail.com) 32 | -------------------------------------------------------------------------------- /src/Framework/Properties.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include "StdHdr.h" 26 | #include "Properties.h" 27 | 28 | Property::Property(const Property & other) : 29 | type(other.type), 30 | vInt(other.vInt), 31 | vFloat(other.vFloat), 32 | vStr(other.vStr) 33 | { 34 | } 35 | 36 | Property::Property(int v) : type(vtInt), vInt(v), vFloat(0.) 37 | { 38 | } 39 | 40 | Property::Property(float v) : type(vtFloat), vInt(0), vFloat(v) 41 | { 42 | } 43 | 44 | Property::Property(const String & v) : type(vtString), vInt(0), vFloat(0.0), vStr(v) 45 | { 46 | } 47 | 48 | Property & Property::operator=(const Property & p) 49 | { 50 | type = p.type; 51 | switch (p.type) 52 | { 53 | case vtInt: 54 | vInt = (int)p; 55 | break; 56 | 57 | case vtFloat: 58 | vFloat = (float)p; 59 | break; 60 | 61 | case vtString: 62 | vStr = p.operator const String(); 63 | break; 64 | } 65 | return *this; 66 | } 67 | 68 | Property::operator int64_t() const 69 | { 70 | switch (type) 71 | { 72 | case vtInt: 73 | return vInt; 74 | 75 | case vtFloat: 76 | return (int64_t)vFloat; 77 | 78 | case vtString: 79 | return vStr.AsInt64(); 80 | } 81 | return 0; 82 | } 83 | 84 | Property::operator int() const 85 | { 86 | switch (type) 87 | { 88 | case vtInt: 89 | return (int)vInt; 90 | 91 | case vtFloat: 92 | return (int)vFloat; 93 | 94 | case vtString: 95 | return vStr.AsInt(); 96 | } 97 | return 0; 98 | } 99 | 100 | Property::operator bool() const 101 | { 102 | switch (type) 103 | { 104 | case vtInt: 105 | return vInt != 0; 106 | 107 | case vtFloat: 108 | return vFloat != 0; 109 | 110 | case vtString: 111 | return vStr == L"1"; 112 | } 113 | return false; 114 | } 115 | 116 | Property::operator float() const 117 | { 118 | switch (type) 119 | { 120 | case vtInt: 121 | return (float)vInt; 122 | 123 | case vtFloat: 124 | return vFloat; 125 | 126 | case vtString: 127 | return vStr.AsFloat(); 128 | } 129 | return 0; 130 | } 131 | 132 | Property::operator const String() const 133 | { 134 | switch (type) 135 | { 136 | case vtInt: 137 | return String(vInt); 138 | 139 | case vtFloat: 140 | return String(vFloat); 141 | 142 | case vtString: 143 | return vStr; 144 | } 145 | return L""; 146 | } 147 | 148 | bool Property::operator==(const Property & v) const 149 | { 150 | switch (type) 151 | { 152 | case vtInt: 153 | return operator==((int)v); 154 | 155 | case vtFloat: 156 | return operator==((float)v); 157 | 158 | case vtString: 159 | return operator==(v.operator const String()); 160 | } 161 | return false; 162 | } 163 | -------------------------------------------------------------------------------- /src/FarSettings.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "FarSettings.h" 3 | #include "guid.hpp" 4 | 5 | #include "SDK/plugin.hpp" 6 | 7 | FarSettings::FarSettings() : 8 | handle(INVALID_HANDLE_VALUE), dirId(0), nAttachments(0) 9 | { 10 | } 11 | 12 | FarSettings::~FarSettings() 13 | { 14 | while (nAttachments != 0) 15 | detach(); 16 | } 17 | 18 | intptr_t FarSettings::control(FAR_SETTINGS_CONTROL_COMMANDS cmd, void * param) 19 | { 20 | return Info.SettingsControl(handle, cmd, 0, param); 21 | } 22 | 23 | void FarSettings::detach() 24 | { 25 | if (--nAttachments == 0) 26 | { 27 | if (handle != INVALID_HANDLE_VALUE) 28 | { 29 | control(SCTL_FREE); 30 | handle = INVALID_HANDLE_VALUE; 31 | dirId = 0; 32 | } 33 | } 34 | } 35 | 36 | bool FarSettings::attach() 37 | { 38 | if (nAttachments++ == 0) 39 | { 40 | FarSettingsCreate fsc = { sizeof(FarSettingsCreate) }; 41 | fsc.Guid = MainGuid; 42 | if (!control(SCTL_CREATE, &fsc)) 43 | { 44 | nAttachments--; 45 | return false; 46 | } 47 | handle = fsc.Handle; 48 | FarSettingsValue fsv = { sizeof(FarSettingsValue) }; 49 | fsv.Root = dirId; 50 | fsv.Value = L"FileCopyEx3Settings"; 51 | intptr_t dir_id = control(SCTL_CREATESUBKEY, &fsv); 52 | if (dir_id != 0) 53 | { 54 | dirId = dir_id; 55 | } 56 | } 57 | return true; 58 | } 59 | 60 | bool FarSettings::get(const String & name, String & value) 61 | { 62 | if (!attach()) 63 | return false; 64 | FarSettingsItem fsi = { sizeof(FarSettingsItem) }; 65 | fsi.Root = dirId; 66 | fsi.Name = name.c_str(); 67 | fsi.Type = FST_STRING; 68 | bool ok = control(SCTL_GET, &fsi) != 0; 69 | if (ok) 70 | value = fsi.String; 71 | detach(); 72 | return ok; 73 | } 74 | 75 | bool FarSettings::set(const String & name, const String & value) 76 | { 77 | if (!attach()) 78 | return false; 79 | FarSettingsItem fsi = { sizeof(FarSettingsItem) }; 80 | fsi.Root = dirId; 81 | fsi.Name = name.c_str(); 82 | fsi.Type = FST_STRING; 83 | fsi.String = value.c_str(); 84 | bool ok = control(SCTL_SET, &fsi) != 0; 85 | detach(); 86 | return ok; 87 | } 88 | 89 | bool FarSettings::list(ParamInfoVector & res) 90 | { 91 | if (!attach()) 92 | return false; 93 | FarSettingsEnum fse = { sizeof(FarSettingsEnum) }; 94 | fse.Root = dirId; 95 | bool ok = control(SCTL_ENUM, &fse) != 0; 96 | if (ok) 97 | { 98 | res.clear(); 99 | for (size_t Index = 0; Index < fse.Count; Index++) 100 | { 101 | if (fse.Items[Index].Type == FST_STRING) 102 | { 103 | res.push_back(ParamInfo(fse.Items[Index].Name, fse.Items[Index].Type)); 104 | } 105 | } 106 | } 107 | detach(); 108 | return ok; 109 | } 110 | 111 | bool saveOptions(const PropertyMap & options, FarSettings & settings) 112 | { 113 | bool ok = settings.attach(); 114 | if (ok) 115 | { 116 | for (PropertyMap::const_iterator it = options.begin(); it != options.end(); ++it) 117 | { 118 | if (!settings.set(it->first, it->second.operator const String())) 119 | { 120 | ok = false; 121 | } 122 | } 123 | settings.detach(); 124 | } 125 | return ok; 126 | } 127 | 128 | bool loadOptions(PropertyMap & options, FarSettings & settings) 129 | { 130 | bool ok = settings.attach(); 131 | if (ok) 132 | { 133 | FarSettings::ParamInfoVector v; 134 | ok = settings.list(v); 135 | if (ok) 136 | { 137 | for (FarSettings::ParamInfoVector::iterator it = v.begin(); it != v.end(); ++it) 138 | { 139 | String & name = it->name; 140 | String v; 141 | if (settings.get(name, v)) 142 | { 143 | options[name] = v; 144 | } 145 | } 146 | } 147 | settings.detach(); 148 | } 149 | return ok; 150 | } 151 | -------------------------------------------------------------------------------- /src/Framework/ObjString.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include "StdHdr.h" 26 | #include "ObjString.h" 27 | 28 | static bool isbadchar(wchar_t c) 29 | { 30 | return c == L'\0' || c == L'\t' || 31 | c == L'\n' || c == L'\r' || 32 | c == L' '; 33 | } 34 | 35 | String::String(const char * v) 36 | { 37 | if (v != nullptr && v[0] != '\0') 38 | { 39 | size_t len = strlen(v); 40 | str.resize(len); 41 | if (::MultiByteToWideChar(CP_OEMCP, 0, v, (int)len, 42 | &(*str.begin()), (int)len) == 0) 43 | { 44 | str.clear(); 45 | } 46 | } 47 | } 48 | 49 | String String::substr(size_t s, size_t l) const 50 | { 51 | if (s >= len()) 52 | { 53 | return String(); 54 | } 55 | return String(str.substr(s, l)); 56 | } 57 | 58 | String String::trim() const 59 | { 60 | intptr_t start = 0; 61 | intptr_t end = len() - 1; 62 | while (start <= end && isbadchar((*this)[start])) 63 | { 64 | start++; 65 | } 66 | while (end >= start && isbadchar((*this)[end])) 67 | { 68 | end--; 69 | } 70 | return substr(start, end - start + 1); 71 | } 72 | 73 | String String::ltrim() const 74 | { 75 | intptr_t start = 0; 76 | intptr_t end = len() - 1; 77 | while (start <= end && isbadchar((*this)[start])) 78 | { 79 | start++; 80 | } 81 | return substr(start, end - start + 1); 82 | } 83 | 84 | String String::rtrim() const 85 | { 86 | intptr_t start = 0; 87 | intptr_t end = len() - 1; 88 | while (end >= start && isbadchar((*this)[end])) 89 | { 90 | end--; 91 | } 92 | return substr(start, end - start + 1); 93 | } 94 | 95 | String String::trimquotes() const 96 | { 97 | intptr_t start = 0; 98 | intptr_t end = len() - 1; 99 | while (start <= end && ((*this)[start]) == L'"') 100 | { 101 | start++; 102 | } 103 | while (end >= start && ((*this)[end]) == L'"') 104 | { 105 | end--; 106 | } 107 | return substr(start, end - start + 1); 108 | } 109 | 110 | String String::rev() const 111 | { 112 | String res; 113 | res.str.assign(str.rend(), str.rbegin()); 114 | return res; 115 | } 116 | 117 | String String::replace(const String & what, const String & with) const 118 | { 119 | if (what.empty()) 120 | { 121 | return *this; 122 | } 123 | String res; 124 | intptr_t start = 0; 125 | intptr_t p; 126 | while ((p = find(what, start)) != -1) 127 | { 128 | res += substr(start, p - start); 129 | res += with; 130 | start = p + what.len(); 131 | } 132 | res += substr(start); 133 | return res; 134 | } 135 | 136 | String String::toUpper() const 137 | { 138 | String res(str); 139 | ::CharUpperBuff((LPTSTR)res.c_str(), (DWORD)len()); 140 | return res; 141 | } 142 | 143 | String String::toLower() const 144 | { 145 | String res(str); 146 | ::CharLowerBuff((LPTSTR)res.c_str(), (DWORD)len()); 147 | return res; 148 | } 149 | 150 | size_t npos_minus1(size_t pos) 151 | { 152 | return (pos == std::string::npos) ? (size_t)-1 : pos; 153 | } 154 | -------------------------------------------------------------------------------- /changelog.txt: -------------------------------------------------------------------------------- 1 | FileCopyEx3 3.0.8.39 07.12.2014 2 | 3 | * Bugfix: incorrect handling of directories whose name ends with dot symbol 4 | (http://forum.farmanager.com/viewtopic.php?p=126208#p126208) 5 | 6 | FileCopyEx3 3.0.7.38 16.11.2014 7 | 8 | * Use memory buffer 4MB by default for file operations 9 | * Fix use of plugin settings by two and more instances of the app 10 | Thanks to Igor Yudintsev 11 | (https://github.com/michaellukashov/filecopyex3/pull/21) 12 | 13 | FileCopyEx3 3.0.6.35 10.10.2014 14 | 15 | * Improvement: add option for notifications on long operations complete using bass.dll 16 | Thanks to Igor Yudintsev 17 | (http://forum.farmanager.com/viewtopic.php?p=123000#p123000) 18 | * Improvement: show warning when trying to copy large file on disk having FAT filesystem 19 | (http://forum.farmanager.com/viewtopic.php?p=123277#p123277) 20 | * Bugfix: fix copy to network share 21 | Thanks to Igor Yudintsev 22 | (https://github.com/michaellukashov/filecopyex3/pull/16) 23 | * Improvement: copy long (> 255 symbols) nested paths 24 | 25 | FileCopyEx3 3.0.5.29 01.09.2014 26 | 27 | * Bugfix: Unicode resource files were not correctly loaded 28 | Thanks to Igor Yudintsev 29 | (http://forum.farmanager.com/viewtopic.php?f=5&t=583&p=122045#p122045) 30 | (https://github.com/michaellukashov/filecopyex3/pull/16) 31 | * Improvement: ShiftF5/F6 handling 32 | (http://forum.farmanager.com/viewtopic.php?f=5&t=583&p=121935#p121838) 33 | * Bugfix: Settings --> Hotkeys --> "[] Bind Extended copy to F5/F6" option cannot be unset 34 | (http://forum.farmanager.com/viewtopic.php?f=5&t=583&p=121873#p121838) 35 | * Bugfix: Prevent locking source directory 36 | (http://forum.farmanager.com/viewtopic.php?f=5&t=583&p=121873#p121815) 37 | 38 | FileCopyEx3 3.0.4.23 25.08.2014 39 | 40 | * Fix issue #12: Cannot cancel copy process 41 | (https://github.com/michaellukashov/filecopyex3/issues/12) 42 | * Bugfix: Key bindings settings were not stored 43 | * Fix issue #7: F5/F6 not working 44 | (https://github.com/michaellukashov/filecopyex3/issues/7) 45 | 46 | FileCopyEx3 3.0.3.20 23.08.2014 47 | 48 | * Fix for corrupt non-ASCII characters in descript.ion after copying a file 49 | Thanks to Igor Yudintsev 50 | (https://github.com/michaellukashov/filecopyex3/pull/11) 51 | * Fix issue #8: Help is not working 52 | (https://github.com/michaellukashov/filecopyex3/issues/8) 53 | (http://forum.farmanager.com/viewtopic.php?p=120961#p120961) 54 | * Fix googlecode issue #12, github issue #10: Check if destination file exists 55 | (https://code.google.com/p/filecopyex3/issues/detail?id=12) 56 | (https://github.com/michaellukashov/filecopyex3/issues/10) 57 | 58 | FileCopyEx3 3.0.2.16 01.08.2014 59 | 60 | * Bugfix: "Copy file under cursor", "Move file under cursor" was not working 61 | * Fix issue #3: "Scanning directories" dialog is not correctly redrawed 62 | (https://github.com/michaellukashov/filecopyex3/issues/3) 63 | * Fix issue #4: Wrong file mask handling 64 | (https://github.com/michaellukashov/filecopyex3/issues/4) 65 | 66 | FileCopyEx3 3.0.1.14 28.07.2014 67 | 68 | * Fix issue #2: Scan folders dialog is not redrawed 69 | (https://github.com/michaellukashov/filecopyex3/issues/2) 70 | * Fix issue #1: Error trying to allocate memory 71 | (https://github.com/michaellukashov/filecopyex3/issues/1) 72 | 73 | FileCopyEx3 3.0.0.11 15.07.2014 74 | 75 | * Fix issue 4: Cursor jumps after copying files 76 | (https://code.google.com/p/filecopyex3/issues/detail?id=4) 77 | * Fix issue 9: Cannot delete the file 78 | (https://code.google.com/p/filecopyex3/issues/detail?id=9) 79 | * Fix issue 10: Dialog not redrawed 80 | (https://code.google.com/p/filecopyex3/issues/detail?id=10) 81 | * Fix issue 11: Files locked after copy operation is canceled 82 | (https://code.google.com/p/filecopyex3/issues/detail?id=11) 83 | * Fix issue 13: Files locked after copying 84 | (https://code.google.com/p/filecopyex3/issues/detail?id=13) 85 | * Fix memory issues 86 | 87 | build 10 88 | * bugfix: setFileSizeAndTime2: opened handle was not closed 89 | (http://forum.farmanager.com/viewtopic.php?f=5&t=583&p=112815&hilit=filecopyex#p114280) 90 | * fix memory issues 91 | 92 | build 9 93 | + добавлен перевод на испанский (автор - Mauro72) 94 | + сохранение всех параметров из расширенного диалога копирования 95 | 96 | build 8 97 | + Добавлено опциональное копирование времени создания, изменния и последнего доступа 98 | 99 | build 7 100 | * Quick&Dirty решение для создания макросов (файлы с ними создаются напрямую, без использования API) 101 | 102 | build 6 103 | * Плагин в Release-версии падал 104 | 105 | build 5 106 | * размеры файла форматируются с учетом системного разделителя 107 | 108 | build 4 109 | * Собран под Far3 API -------------------------------------------------------------------------------- /src/Framework/DescList.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010\nIdea & core: Max Antipin\nCoding: Serge Cheperis aka craZZy\nBugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky\nSpecial thanks to Vitaliy Tsubin\nFar 2 (32 & 64 bit) full unicode version by djdron 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | #include "StdHdr.h" 21 | #include "DescList.h" 22 | #include "FileUtils.h" 23 | 24 | DescList::DescList() 25 | { 26 | } 27 | 28 | bool DescList::LoadFromFile(const String & lfn) 29 | { 30 | StringVector temp; 31 | if (!temp.loadFromFile(lfn)) 32 | { 33 | return false; 34 | } 35 | return LoadFromList(temp); 36 | } 37 | 38 | bool DescList::LoadFromList(StringVector & list) 39 | { 40 | String fn, desc; 41 | for (size_t Index = 0; Index < list.Count(); Index++) 42 | { 43 | String s = list[Index]; 44 | wchar_t c = s[0]; 45 | if (c != L'\t' && c != L' ' && c != L'>' && c) 46 | { 47 | if (!fn.empty()) 48 | { 49 | names[fn] = Data(desc, 0); 50 | fn.Clear(); 51 | desc.Clear(); 52 | } 53 | if (c == L'"') 54 | { 55 | size_t lf = s.substr(1).find('"'); 56 | if (lf != (size_t)-1) 57 | { 58 | fn = s.substr(1, lf).trim(); 59 | desc = s.substr(lf + 2).trim(); 60 | 61 | } 62 | } 63 | else 64 | { 65 | size_t lf = s.find_first_of(L" \t"); 66 | if (lf != (size_t)-1) 67 | { 68 | fn = s.substr(0, lf).trim(); 69 | desc = s.substr(lf + 1).trim(); 70 | } 71 | else 72 | { 73 | fn = s; 74 | desc.Clear(); 75 | } 76 | } 77 | } 78 | else 79 | { 80 | desc += String(L"\n") + s; 81 | } 82 | } 83 | if (!fn.empty()) 84 | { 85 | names[fn] = Data(desc, 0); 86 | } 87 | return true; 88 | } 89 | 90 | const int dlNoMerge = 1; 91 | const int dlNoSave = 2; 92 | 93 | bool DescList::SaveToFile(const String & fn) 94 | { 95 | StringVector temp; 96 | for (DescListMap::iterator it = names.begin(); it != names.end(); ++it) 97 | { 98 | if (!(it->second.flags & dlNoSave)) 99 | { 100 | String s; 101 | if (it->first.find(' ')) 102 | { 103 | s = String(L"\"") + it->first + L"\""; 104 | } 105 | else 106 | { 107 | s = it->first; 108 | } 109 | s += String(L" ") + it->second.desc; 110 | temp.AddString(s); 111 | } 112 | } 113 | if (temp.Count() > 0) 114 | { 115 | return temp.saveToFile(fn); 116 | } 117 | if (FDelete(fn) || ::GetLastError() == ERROR_FILE_NOT_FOUND) 118 | { 119 | return true; 120 | } 121 | return false; 122 | } 123 | 124 | void DescList::Merge(DescList & add) 125 | { 126 | for (DescListMap::iterator it = add.names.begin(); it != add.names.end(); ++it) 127 | { 128 | if (!(it->second.flags & dlNoMerge)) 129 | { 130 | String name = it->first; 131 | names[name] = it->second; 132 | } 133 | } 134 | } 135 | 136 | void DescList::setFlag(const String & fn, uint32_t flag, uint32_t v) 137 | { 138 | DescListMap::iterator it = names.find(fn); 139 | if (it != names.end()) 140 | { 141 | if (v) 142 | { 143 | it->second.flags &= ~flag; 144 | } 145 | else 146 | { 147 | it->second.flags |= flag; 148 | } 149 | } 150 | } 151 | 152 | void DescList::SetMergeFlag(const String & fn, uint32_t v) 153 | { 154 | setFlag(fn, dlNoMerge, v); 155 | } 156 | 157 | void DescList::SetSaveFlag(const String & fn, uint32_t v) 158 | { 159 | setFlag(fn, dlNoSave, v); 160 | } 161 | 162 | void DescList::setAllFlags(uint32_t flag, uint32_t v) 163 | { 164 | for (DescListMap::iterator it = names.begin(); it != names.end(); ++it) 165 | { 166 | if (v) 167 | { 168 | it->second.flags &= ~flag; 169 | } 170 | else 171 | { 172 | it->second.flags |= dlNoMerge; 173 | } 174 | } 175 | } 176 | 177 | void DescList::SetAllMergeFlags(int v) 178 | { 179 | setAllFlags(dlNoMerge, v); 180 | } 181 | 182 | void DescList::SetAllSaveFlags(int v) 183 | { 184 | setAllFlags(dlNoSave, v); 185 | } 186 | 187 | void DescList::Rename(const String & src, const String & dst, int changeName) 188 | { 189 | if (src != dst) 190 | { 191 | names[dst] = names[src]; 192 | names.erase(src); 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /src/Framework/Node.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include "StdHdr.h" 26 | #include "Node.h" 27 | #include "FrameworkUtils.h" 28 | #include "StrUtils.h" 29 | #include "ObjectManager.h" 30 | 31 | Node::Node() 32 | { 33 | parent = nullptr; 34 | payload = new Payload(); 35 | } 36 | 37 | void Node::init(Payload * _payload, Node * _parent) 38 | { 39 | delete payload; 40 | 41 | payload = _payload; 42 | parent = _parent; 43 | if (parent) 44 | { 45 | parent->childs.push_back(this); 46 | } 47 | } 48 | 49 | Node::~Node() 50 | { 51 | ClearChilds(); 52 | delete payload; 53 | } 54 | 55 | Property & Node::operator()(const String & v) 56 | { 57 | return getPayload()(v); 58 | } 59 | 60 | Payload & Node::getPayload() const 61 | { 62 | static Payload nullPayload; 63 | return payload ? *payload : nullPayload; 64 | } 65 | 66 | const String Node::getName() const 67 | { 68 | return getPayload().getName(); 69 | } 70 | 71 | int Node::LoadFrom(FILE * f) 72 | { 73 | StringVector temp; 74 | return temp.loadFromFile(f) && LoadFromList(temp) != 0; 75 | } 76 | 77 | bool Node::Load(const String & fn) 78 | { 79 | StringVector temp; 80 | return temp.loadFromFile(fn) && LoadFromList(temp) != 0; 81 | } 82 | 83 | Node & Node::child(const String & v) 84 | { 85 | for (size_t Index = 0; Index < childs.size(); ++Index) 86 | { 87 | if (childs[Index]->getName() == v) 88 | { 89 | return child(Index); 90 | } 91 | } 92 | FWError(Format(L"Request to undefined object %s", v.ptr())); 93 | static Node nullNode; 94 | return nullNode; 95 | } 96 | 97 | void Node::ClearChilds() 98 | { 99 | for (size_t Index = 0; Index < childs.size(); ++Index) 100 | { 101 | delete childs[Index]; 102 | } 103 | childs.clear(); 104 | } 105 | 106 | size_t Node::LoadFromList(StringParent & list, size_t start) 107 | { 108 | ClearChilds(); 109 | BeforeLoad(); 110 | 111 | size_t res = list.Count() - 1; 112 | 113 | for (size_t Index = start; Index < list.Count(); Index++) 114 | { 115 | String line = list[Index].trim(); 116 | if (line == L"end") 117 | { 118 | res = Index; 119 | break; 120 | } 121 | else if (!line.ncmp(L"object", 6)) 122 | { 123 | size_t p = line.find(' '); 124 | size_t p1 = line.find(':'); 125 | if (p != (size_t)-1 && p1 != (size_t)-1 && p < p1) 126 | { 127 | String pname = line.substr(p + 1, p1 - p - 1).trim(); 128 | String ptype = line.substr(p1 + 1).trim(); 129 | Node * obj = objectManager->create(ptype, pname, this); 130 | if (obj) 131 | { 132 | Index = obj->LoadFromList(list, Index + 1); 133 | } 134 | else 135 | { 136 | FWError(Format(L"Object type %s is undefined", ptype.ptr())); 137 | } 138 | } 139 | } 140 | else 141 | { 142 | size_t p = line.find('='); 143 | if (p != (size_t)-1) 144 | { 145 | String pline = line.substr(0, p).trim(); 146 | String pval = line.substr(p + 1).trim().trimquotes(); 147 | (*this)(pline) = pval; 148 | } 149 | } 150 | } 151 | 152 | AfterLoad(); 153 | getPayload().propSave(); // loadedProp = prop; 154 | return res; 155 | } 156 | 157 | /* 158 | void Node::SaveToList(StringVector &list, int clear, int level) 159 | { 160 | if (clear) list.Clear(); 161 | String pfx; 162 | for (int j=0; jPropertyNames.Count(); i++) 164 | { 165 | list.Add(pfx+_class->PropertyNames[i]+"=" 166 | +properties[_class->PropertyNames.Values(i)]); 167 | } 168 | for (int i=0; iName()+": "+childs[i]->Type()); 171 | childs[i]->SaveToList(list, 0, level+1); 172 | list.Add(pfx+"end"); 173 | } 174 | } 175 | */ 176 | 177 | void Node::ReloadProperties() const 178 | { 179 | getPayload().propLoad(); 180 | } 181 | 182 | void Node::ReloadPropertiesRecursive() 183 | { 184 | ReloadProperties(); 185 | for (size_t Index = 0; Index < childs.size(); Index++) 186 | { 187 | childs[Index]->ReloadPropertiesRecursive(); 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /src/ui.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include "Common.h" 26 | #include "guid.hpp" 27 | #include "ui.h" 28 | 29 | intptr_t ShowMessage(const String & title, const String & msg, uint32_t Flags) 30 | { 31 | return ShowMessageHelp(title, msg, Flags, L""); 32 | } 33 | 34 | intptr_t ShowMessageOK(const String & title, const String & msg) 35 | { 36 | return ShowMessage(title, msg, FMSG_MB_OK); 37 | } 38 | 39 | intptr_t ShowMessageHelp(const String & title, const String & msg, uint32_t Flags, const String & help) 40 | { 41 | String msgbuf = title + L"\n" + msg + L"\n\x01"; 42 | intptr_t res = Info.Message(&MainGuid, &UnkGuid, 43 | Flags | FMSG_ALLINONE, 44 | help.ptr(), 45 | reinterpret_cast(msgbuf.ptr()), 46 | 0, 0 47 | ); 48 | return res; 49 | } 50 | 51 | intptr_t ShowMessageEx(const String & title, const String & msg, 52 | const String & buttons, uint32_t flags) 53 | { 54 | return ShowMessageExHelp(title, msg, buttons, flags, L""); 55 | } 56 | 57 | intptr_t ShowMessageExHelp(const String & title, const String & msg, 58 | const String & buttons, uint32_t flags, const String & help) 59 | { 60 | size_t nb = 0; 61 | for (const wchar_t * p = buttons.ptr(); *p; p++) 62 | { 63 | if (*p == L'\n') 64 | nb++; 65 | } 66 | String msgbuf = title + L"\n" + msg + L"\n\x01\n" + buttons; 67 | intptr_t res = Info.Message(&MainGuid, &UnkGuid, flags | FMSG_ALLINONE, 68 | help.ptr(), 69 | reinterpret_cast(msgbuf.ptr()), 70 | 0, nb + 1 71 | ); 72 | return res; 73 | } 74 | 75 | intptr_t msgw() 76 | { 77 | return 50; 78 | } 79 | 80 | void Error(const String & s, intptr_t code) 81 | { 82 | ShowMessageEx(LOC(L"Framework.Error"), 83 | s + L"\n" + SplitWidth(GetErrText(code), msgw()), 84 | LOC(L"Framework.OK"), 85 | FMSG_WARNING 86 | ); 87 | } 88 | 89 | void Error2(const String & s, const String & fn, intptr_t code) 90 | { 91 | ShowMessageEx(LOC(L"Framework.Error"), 92 | s + L"\n" + FormatWidthNoExt(fn, msgw()) + L"\n" + SplitWidth(GetErrText(code), msgw()), 93 | LOC(L"Framework.OK"), 94 | FMSG_WARNING 95 | ); 96 | } 97 | 98 | intptr_t Error2RS(const String & s, const String & fn, intptr_t code) 99 | { 100 | intptr_t res = ShowMessageEx(LOC(L"Framework.Error"), 101 | s + L"\n" + FormatWidthNoExt(fn, msgw()) + L"\n" + SplitWidth(GetErrText(code), msgw()), 102 | LOC(L"Framework.Retry") + L"\n" + LOC(L"Framework.Skip"), 103 | FMSG_WARNING 104 | ); 105 | if (res == 0) 106 | { 107 | return RES_RETRY; 108 | } 109 | return RES_SKIP; 110 | } 111 | 112 | String GetErrText(intptr_t code) 113 | { 114 | wchar_t buf[1024]; 115 | ::FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, (DWORD)code, 0, buf, _countof(buf), nullptr); 116 | return buf; 117 | } 118 | 119 | String FormatWidth(const String & s, intptr_t len) 120 | { 121 | intptr_t dif = (intptr_t)s.len() - len; 122 | if (dif > 0) 123 | { 124 | return String(L"...") + s.right(len - 3); 125 | } 126 | else 127 | { 128 | return s + String(' ', -dif); 129 | } 130 | } 131 | 132 | String FormatWidthNoExt(const String & s, intptr_t len) 133 | { 134 | intptr_t dif = (intptr_t)s.len() - len; 135 | if (dif > 0) 136 | { 137 | return String(L"...") + s.right(len - 3); 138 | } 139 | else 140 | { 141 | return s; 142 | } 143 | } 144 | 145 | String SplitWidth(const String & s, intptr_t w) 146 | { 147 | String res; 148 | res.reserve(s.len()); 149 | intptr_t curW = 0; 150 | for (size_t Index = 0; Index < s.len(); Index++) 151 | { 152 | wchar_t c = s[Index]; 153 | 154 | if (c == L'\n' || c == L'\r') 155 | { 156 | continue; 157 | } 158 | if (c == L' ' && (curW > w)) 159 | { 160 | res += L'\n'; 161 | curW = 0; 162 | continue; 163 | } 164 | res += c; 165 | curW++; 166 | } 167 | return res; 168 | } 169 | -------------------------------------------------------------------------------- /src/Framework/ObjString.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | size_t npos_minus1(size_t pos); 31 | 32 | class String 33 | { 34 | public: 35 | String() {} 36 | String(const String & str) : str(str.str) {} 37 | 38 | explicit String(const char * v); 39 | 40 | explicit String(wchar_t ch, size_t len) 41 | { 42 | str.resize(len, ch); 43 | } 44 | 45 | String(const wchar_t * v) : str(v) 46 | { 47 | } 48 | 49 | explicit String(const wchar_t * v, size_t len) : str(v, len) 50 | { 51 | } 52 | 53 | explicit String(const std::wstring & v) : str(v) 54 | { 55 | } 56 | 57 | inline wchar_t operator[](intptr_t i) const 58 | { 59 | if (i >= 0 && (size_t)i < str.length()) 60 | return str[i]; 61 | else 62 | return 0; 63 | } 64 | 65 | explicit String(int v) 66 | { 67 | wchar_t buf[64]; 68 | _itow_s(v, buf, 64, 10); 69 | str = buf; 70 | } 71 | 72 | explicit String(size_t v) 73 | { 74 | wchar_t buf[64]; 75 | _i64tow_s((int64_t)v, buf, 64, 10); 76 | str = buf; 77 | } 78 | 79 | explicit String(int64_t v) 80 | { 81 | wchar_t buf[64]; 82 | _i64tow_s(v, buf, 64, 10); 83 | str = buf; 84 | } 85 | 86 | explicit String(float v) 87 | { 88 | wchar_t buf[64]; 89 | swprintf_s(buf, 64, L"%g", v); 90 | str = buf; 91 | } 92 | 93 | explicit String(bool v) : str(v ? L"1" : L"0") 94 | { 95 | } 96 | 97 | inline bool operator==(const String & v) const { return cmp(v) == 0; } 98 | inline bool operator!=(const String & v) const { return cmp(v) != 0; } 99 | inline bool operator<(const String & v) const { return cmp(v) < 0; } 100 | inline bool operator>(const String & v) const { return cmp(v) > 0; } 101 | inline bool operator<=(const String & v) const { return cmp(v) <= 0; } 102 | inline bool operator>=(const String & v) const { return cmp(v) >= 0; } 103 | inline void operator+=(const String & v) { str += v.str; } 104 | inline void operator+=(wchar_t c) { str += c; } 105 | const String operator+(const String & v) const { return String(str + v.str); } 106 | 107 | inline size_t len() const { return str.length(); } 108 | inline bool empty() const { return str.empty(); } 109 | 110 | inline void Clear() { str.clear(); } 111 | inline bool IsEmpty() const { return str.empty(); } 112 | 113 | int AsInt() const { return _wtoi(ptr()); } 114 | int64_t AsInt64() const { return _wtoi64(ptr()); } 115 | float AsFloat() const { return (float)_wtof(ptr()); } 116 | bool AsBool() const { return (*this) == L"1"; } 117 | void copyTo(wchar_t * buf, size_t sz) const { wcscpy_s(buf, sz, ptr()); } 118 | 119 | int cmp(const String & v) const { return ncmp(v, size_t(-1)); } 120 | int icmp(const String & v) const { return nicmp(v, size_t(-1)); } 121 | int ncmp(const String & v, size_t sz) const { return wcsncmp(ptr(), v.ptr(), sz); } 122 | int nicmp(const String & v, size_t sz) const { return _wcsnicmp(ptr(), v.ptr(), sz); } 123 | 124 | String substr(size_t pos = 0, size_t len = std::string::npos) const; 125 | 126 | const String left(size_t n) const { return substr(0, n); } 127 | const String right(size_t n) const { return substr(len() - n, n); } 128 | 129 | String trim() const; 130 | String ltrim() const; 131 | String rtrim() const; 132 | String trimquotes() const; 133 | 134 | String rev() const; 135 | 136 | String replace(const String & what, const String & with) const; 137 | String toUpper() const; 138 | String toLower() const; 139 | 140 | size_t find(const String & v, size_t start = 0) const { return npos_minus1(str.find(v.str, start)); } 141 | size_t find(wchar_t v, size_t start = 0) const { return npos_minus1(str.find(v, start)); } 142 | size_t find_first_of(const String & v, size_t start = 0) const { return npos_minus1(str.find_first_of(v.str, start)); } 143 | size_t rfind(const String & v, size_t start = std::string::npos) const { return npos_minus1(str.rfind(v.str, start)); } 144 | size_t rfind(wchar_t v, size_t start = std::string::npos) const { return npos_minus1(str.rfind(v, start)); } 145 | size_t find_last_of(const String & v, size_t start = std::string::npos) const { return npos_minus1(str.find_last_of(v.str, start)); } 146 | 147 | const wchar_t * ptr() const { return c_str(); } 148 | const wchar_t * c_str() const { return str.c_str(); } 149 | 150 | void reserve(size_t n = 0) { str.reserve(n); } 151 | 152 | private: 153 | std::wstring str; 154 | }; 155 | 156 | -------------------------------------------------------------------------------- /src/Framework/StrUtils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include 26 | #include "StdHdr.h" 27 | #include "ObjString.h" 28 | #include "FrameworkUtils.h" 29 | 30 | String Format(const wchar_t * fmt, ...) 31 | { 32 | wchar_t buf[8192]; 33 | va_list args; 34 | va_start(args, fmt); 35 | _vsnwprintf_s(buf, _countof(buf), fmt, args); 36 | va_end(args); 37 | return buf; 38 | } 39 | 40 | String FormatNum(int64_t n) 41 | { 42 | static bool first = true; 43 | static NUMBERFMT fmt; 44 | static wchar_t DecimalSep[4]; 45 | static wchar_t ThousandSep[4]; 46 | 47 | if (first) 48 | { 49 | GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, ThousandSep, ARRAYSIZE(ThousandSep)); 50 | GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, DecimalSep, ARRAYSIZE(DecimalSep)); 51 | DecimalSep[1] = 0; //В винде сепараторы цифр могут быть больше одного символа 52 | ThousandSep[1] = 0; //но для нас это будет не очень хорошо 53 | /* 54 | if (LOWORD(Global->Opt->FormatNumberSeparators)) { 55 | *DecimalSep=LOWORD(Global->Opt->FormatNumberSeparators); 56 | } 57 | 58 | if (HIWORD(Global->Opt->FormatNumberSeparators)) { 59 | *ThousandSep=HIWORD(Global->Opt->FormatNumberSeparators); 60 | } 61 | */ 62 | 63 | fmt.LeadingZero = 1; 64 | fmt.Grouping = 3; 65 | fmt.lpDecimalSep = DecimalSep; 66 | fmt.lpThousandSep = ThousandSep; 67 | fmt.NegativeOrder = 1; 68 | fmt.NumDigits = 0; 69 | first = false; 70 | } 71 | 72 | String strSrc(n); 73 | String strDest; 74 | int size = ::GetNumberFormat(LOCALE_USER_DEFAULT, 0, strSrc.c_str(), &fmt, nullptr, 0); 75 | if (size != 0) 76 | { 77 | wchar_t * lpwszDest = new wchar_t[size]; 78 | ::GetNumberFormat(LOCALE_USER_DEFAULT, 0, strSrc.c_str(), &fmt, lpwszDest, size); 79 | strDest = lpwszDest; 80 | delete[] lpwszDest; 81 | } 82 | 83 | return strDest; 84 | } 85 | 86 | String FormatTime(const FILETIME & ft) 87 | { 88 | FILETIME ft1; 89 | SYSTEMTIME st; 90 | ::FileTimeToLocalFileTime(&ft, &ft1); 91 | ::FileTimeToSystemTime(&ft1, &st); 92 | return Format(L"%02d.%02d.%04d %02d:%02d:%02d", 93 | (int)st.wDay, (int)st.wMonth, (int)st.wYear, 94 | (int)st.wHour, (int)st.wMinute, (int)st.wSecond); 95 | } 96 | 97 | String FormatProgress(int64_t cb, int64_t total) 98 | { 99 | int64_t n = total; 100 | int pw = 0; 101 | int64_t div = 1; 102 | while (n > 999999) 103 | { 104 | div *= 1024; 105 | n /= 1024; 106 | pw++; 107 | } 108 | String un; 109 | switch (pw) 110 | { 111 | case 0: 112 | un = LOC(L"Engine.Bytes"); 113 | break; 114 | case 1: 115 | un = LOC(L"Engine.Kb"); 116 | break; 117 | case 2: 118 | un = LOC(L"Engine.Mb"); 119 | break; 120 | case 3: 121 | un = LOC(L"Engine.Gb"); 122 | break; 123 | case 4: 124 | un = LOC(L"Engine.Tb"); 125 | break; 126 | case 5: 127 | un = LOC(L"Engine.Pb"); 128 | break; 129 | } 130 | return Format(L"%s %s %s %s [%d%%]", FormatNum(cb / div).ptr(), LOC(L"Engine.Of").ptr(), 131 | FormatNum(total / div).ptr(), un.ptr(), (int)(total ? (float)cb / total * 100 : 0)); 132 | } 133 | 134 | String FormatSpeed(int64_t cb) 135 | { 136 | int64_t n = cb; 137 | int pw = 0; 138 | int64_t div = 1; 139 | while (n >= 100000) 140 | { 141 | div *= 1024; 142 | n /= 1024; 143 | pw++; 144 | } 145 | String un; 146 | switch (pw) 147 | { 148 | case 0: 149 | un = LOC(L"Engine.Bytes"); 150 | break; 151 | case 1: 152 | un = LOC(L"Engine.Kb"); 153 | break; 154 | case 2: 155 | un = LOC(L"Engine.Mb"); 156 | break; 157 | case 3: 158 | un = LOC(L"Engine.Gb"); 159 | break; 160 | case 4: 161 | un = LOC(L"Engine.Tb"); 162 | break; 163 | case 5: 164 | un = LOC(L"Engine.Pb"); 165 | break; 166 | } 167 | 168 | return Format(L"%s %s/%s", FormatNum(cb / div).ptr(), un.ptr(), LOC(L"Engine.Sec").ptr()); 169 | } 170 | 171 | String FormatValue(int64_t Value) 172 | { 173 | int pw = 0; 174 | while (Value >= 100000) 175 | { 176 | Value /= 1024; 177 | pw++; 178 | } 179 | String UnitStr; 180 | switch (pw) 181 | { 182 | case 0: 183 | UnitStr = LOC(L"Engine.Bytes"); 184 | break; 185 | case 1: 186 | UnitStr = LOC(L"Engine.Kb"); 187 | break; 188 | case 2: 189 | UnitStr = LOC(L"Engine.Mb"); 190 | break; 191 | case 3: 192 | UnitStr = LOC(L"Engine.Gb"); 193 | break; 194 | case 4: 195 | UnitStr = LOC(L"Engine.Tb"); 196 | break; 197 | case 5: 198 | UnitStr = LOC(L"Engine.Pb"); 199 | break; 200 | } 201 | return Format(L"%s %s", FormatNum(Value).ptr(), UnitStr.ptr()); 202 | } 203 | -------------------------------------------------------------------------------- /src/Framework/StringParent.cpp: -------------------------------------------------------------------------------- 1 | #include "StdHdr.h" 2 | #include "StringParent.h" 3 | #include "FrameworkUtils.h" 4 | #include "FileUtils.h" 5 | 6 | bool StringParent::loadFromFile(FILE * f) 7 | { 8 | Clear(); 9 | union 10 | { 11 | char c[2]; 12 | wchar_t uc; 13 | } sign; 14 | size_t read = fread(&sign, 1, sizeof(sign), f); 15 | bool unicode = (read == 2) && (sign.uc == 0xFEFF || sign.uc == 0xFFFE); 16 | bool inv = (unicode) && (sign.uc == 0xFFFE); 17 | const size_t bsize = DEFAULT_SECTOR_SIZE, ssize = DEFAULT_SECTOR_SIZE; 18 | if (unicode) 19 | { 20 | const wchar_t CR = L'\r', LF = L'\n'; 21 | wchar_t buffer[bsize + 1], string[ssize + 1]; 22 | size_t bpos = 0, spos = 0; 23 | while (1) 24 | { 25 | wchar_t oldc = 0; 26 | read = fread(buffer + bpos, sizeof(wchar_t), bsize - bpos, f); 27 | if (read == 0) 28 | break; 29 | for (size_t Index = 0; Index < read + bpos; Index++) 30 | { 31 | if (inv) 32 | buffer[Index] = ((buffer[Index] & 0x00FF) << 8) | ((buffer[Index] & 0xFF00) >> 8); 33 | if (buffer[Index] == CR || (buffer[Index] == LF && oldc != CR)) 34 | { 35 | string[spos] = 0; 36 | AddString(string); 37 | spos = 0; 38 | } 39 | else 40 | { 41 | if (buffer[Index] != CR && buffer[Index] != LF && spos < ssize) 42 | { 43 | string[spos++] = buffer[Index]; 44 | } 45 | } 46 | oldc = buffer[Index]; 47 | } 48 | bpos = 0; 49 | } 50 | if (spos) 51 | { 52 | string[spos] = 0; 53 | AddString(string); 54 | } 55 | } 56 | else 57 | { 58 | const char CR = '\r', LF = '\n'; 59 | char buffer[bsize + 1], string[ssize + 1]; 60 | size_t bpos = 0, spos = 0; 61 | if (read >= 1) 62 | buffer[0] = sign.c[0]; 63 | if (read >= 2) 64 | buffer[1] = sign.c[1]; 65 | bpos = read; 66 | while (1) 67 | { 68 | char oldc = 0; 69 | read = fread(buffer + bpos, sizeof(char), bsize - bpos, f); 70 | if (read == 0) 71 | break; 72 | for (size_t Index = 0; Index < read + bpos; Index++) 73 | { 74 | if (buffer[Index] == CR || (buffer[Index] == LF && oldc != CR)) 75 | { 76 | string[spos] = 0; 77 | AddString(String(string)); 78 | spos = 0; 79 | } 80 | else 81 | { 82 | if (buffer[Index] != CR && buffer[Index] != LF && spos < ssize) 83 | { 84 | string[spos++] = buffer[Index]; 85 | } 86 | } 87 | oldc = buffer[Index]; 88 | } 89 | bpos = 0; 90 | } 91 | if (spos) 92 | { 93 | string[spos] = 0; 94 | AddString(String(string)); 95 | } 96 | } 97 | return true; 98 | } 99 | 100 | bool StringParent::loadFromFile(const String & fn) 101 | { 102 | FILE * f = nullptr; 103 | _wfopen_s(&f, fn.ptr(), L"rb"); 104 | if (!f) 105 | { 106 | return false; 107 | } 108 | bool res = loadFromFile(f); 109 | fclose(f); 110 | return res; 111 | } 112 | 113 | bool StringParent::saveToFile(FILE * f, TextFormat tf) const 114 | { 115 | if (tf == tfUnicode) 116 | { 117 | uint16_t sign = 0xFEFF; 118 | fwrite(&sign, sizeof(sign), 1, f); 119 | } 120 | else if (tf == tfUnicodeBE) 121 | { 122 | uint16_t sign = 0xFFFE; 123 | fwrite(&sign, sizeof(sign), 1, f); 124 | } 125 | for (size_t Index = 0; Index < Count(); Index++) 126 | { 127 | const String &s = (*this)[Index]; 128 | const int ssize = DEFAULT_SECTOR_SIZE; 129 | if (tf != tfOEM) 130 | { 131 | wchar_t buf[ssize]; 132 | wcscpy_s(buf, ssize, s.c_str()); 133 | if (tf == tfUnicodeBE) 134 | { 135 | for (size_t j = 0; j < wcslen(buf); j++) 136 | { 137 | buf[j] = ((buf[j] & 0x00FF) << 8) | ((buf[j] & 0xFF00) >> 8); 138 | } 139 | } 140 | fwrite(buf, sizeof(wchar_t), wcslen(buf), f); 141 | wcscpy_s(buf, ssize, L"\r\n"); 142 | if (tf == tfUnicodeBE) 143 | { 144 | for (size_t j = 0; j < wcslen(buf); j++) 145 | { 146 | buf[j] = ((buf[j] & 0x00FF) << 8) | ((buf[j] & 0xFF00) >> 8); 147 | } 148 | } 149 | fwrite(buf, sizeof(wchar_t), 2, f); 150 | } 151 | else 152 | { 153 | std::string buf; 154 | 155 | int sizeRequired = ::WideCharToMultiByte(CP_OEMCP, 0, s.c_str(), (int)s.len(), 156 | nullptr, 0, nullptr, nullptr); 157 | if (sizeRequired > 0) 158 | { 159 | buf.resize(sizeRequired); 160 | ::WideCharToMultiByte(CP_OEMCP, 0, s.c_str(), (int)s.len(), 161 | &(*buf.begin()), sizeRequired, nullptr, nullptr); 162 | } 163 | 164 | fwrite(buf.c_str(), sizeof(char), buf.size(), f); 165 | fwrite("\r\n", sizeof(char), 2, f); 166 | } 167 | } 168 | return true; 169 | } 170 | 171 | bool StringParent::saveToFile(const String & fn, TextFormat tf) 172 | { 173 | DWORD attr = ::GetFileAttributes(fn.ptr()); 174 | ::SetFileAttributes(fn.ptr(), FILE_ATTRIBUTE_NORMAL); 175 | FILE * f = nullptr; 176 | _wfopen_s(&f, fn.ptr(), L"wb"); 177 | bool res = false; 178 | if (f) 179 | { 180 | res = saveToFile(f, tf); 181 | fclose(f); 182 | } 183 | if (attr != INVALID_FILE_ATTRIBUTES) 184 | { 185 | ::SetFileAttributes(fn.ptr(), attr); 186 | } 187 | return res; 188 | } 189 | 190 | void StringParent::loadFromString(const wchar_t * s, wchar_t delim) 191 | { 192 | Clear(); 193 | wchar_t * p = (wchar_t *)s; 194 | wchar_t * pp = p; 195 | wchar_t buf[DEFAULT_SECTOR_SIZE]; 196 | do 197 | { 198 | if (!*p || *p == delim) 199 | { 200 | size_t len = __min((size_t)(p - pp), _countof(buf) - 1); 201 | wcsncpy_s(buf, _countof(buf), pp, len); 202 | buf[len] = 0; 203 | pp = p + 1; 204 | AddString(buf); 205 | } 206 | } 207 | while (*p++); 208 | } 209 | 210 | void StringParent::loadFromString(const String & s, wchar_t delim) 211 | { 212 | loadFromString(s.c_str(), delim); 213 | } 214 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(FileCopyEx3) 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | include(${CMAKE_ROOT}/Modules/CMakeDetermineSystem.cmake) 5 | message("system: ${CMAKE_SYSTEM_NAME}") 6 | 7 | #------------------------------------------------------------------------------- 8 | 9 | if(NOT DEFINED CMAKE_BUILD_TYPE) 10 | set(CMAKE_BUILD_TYPE Debug) 11 | endif() 12 | 13 | if(NOT DEFINED FAR_VERSION OR FAR_VERSION STREQUAL "") 14 | set(FAR_VERSION Far3) 15 | endif() 16 | 17 | if(NOT DEFINED CONF) 18 | set(CONF "x86") 19 | endif() 20 | 21 | if(CONF STREQUAL "x86") 22 | set(PLATFORM "Win32") 23 | else() 24 | set(PLATFORM "x64") 25 | endif() 26 | 27 | set(OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${FAR_VERSION}_${CONF}/Plugins/FileCopyEx3) 28 | 29 | #------------------------------------------------------------------------------- 30 | 31 | if(MSVC) 32 | 33 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32 -D_WINDOWS -D_WINDLL -D_USRDL /EHsc /MP2 -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -DUNICODE -D_WINXP -D_HAS_EXCEPTIONS=0" 34 | ) 35 | 36 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32 -D_WINDOWS -D_WINDLL -D_USRDL /MP2 -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -DUNICODE -D_WINXP -D_HAS_EXCEPTIONS=0" 37 | ) 38 | 39 | set(FLAGS_DEBUG "-D_DEBUG /Gm- /MTd /GS" 40 | ) 41 | 42 | set(FLAGS_RELEASE "-U_DEBUG -DNDEBUG /GL /Gm- /MT -Ox -Ob1 -Oi -Os -GF -GS- -Gy /fp:fast" 43 | ) 44 | 45 | else() 46 | 47 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_WINDOWS -D_WINDLL -D_USRDL -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -DUNICODE" 48 | ) 49 | endif() 50 | 51 | 52 | if(PLATFORM STREQUAL "x64") 53 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN64" 54 | ) 55 | endif() 56 | 57 | set(CMAKE_CXX_FLAGS_RELEASE "${FLAGS_RELEASE}") 58 | set(CMAKE_CXX_FLAGS_DEBUG "${FLAGS_DEBUG}") 59 | 60 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${FLAGS_RELEASE}") 61 | 62 | set(CMAKE_LINK_FLAGS 63 | "/DEBUG 64 | /MANIFEST:NO 65 | /TLBID:1 /DYNAMICBASE /SUBSYSTEM:WINDOWS /NOLOGO 66 | /MAP /OPT:REF 67 | /INCREMENTAL:NO 68 | " 69 | ) 70 | 71 | set(CMAKE_EXTRA_LINK_FLAGS "${CMAKE_EXTRA_LINK_FLAGS} /INCREMENTAL:NO /OPT:REF /OPT:ICF" 72 | ) 73 | 74 | #------------------------------------------------------- 75 | 76 | include_directories( 77 | # src 78 | # src/Framework 79 | # src/SDK 80 | ) 81 | 82 | #------------------------------------------------------------------------------- 83 | # target FileCopyEx3 84 | 85 | set(FILECOPYEX_SOURCES 86 | src/ui.cpp 87 | src/tools.cpp 88 | src/taskbarIcon.cpp 89 | src/common.cpp 90 | src/FarSettings.cpp 91 | src/FarProgress.cpp 92 | src/FarPayload.cpp 93 | src/FarNode.cpp 94 | src/FarMenu.cpp 95 | src/FarMacro.cpp 96 | src/FarPlugin.cpp 97 | src/FileCopyEx.cpp 98 | src/EngineTools.cpp 99 | src/Engine.cpp 100 | src/CopyProgress.cpp 101 | src/Framework/StrUtils.cpp 102 | src/Framework/ObjString.cpp 103 | src/Framework/FileUtils.cpp 104 | src/Framework/LocaleUtils.cpp 105 | src/Framework/Properties.cpp 106 | src/Framework/StringParent.cpp 107 | src/Framework/Payload.cpp 108 | src/Framework/ObjectManager.cpp 109 | src/Framework/Node.cpp 110 | src/Framework/FileNameStoreEnum.cpp 111 | src/Framework/DescList.cpp 112 | src/Framework/FrameworkUtils.cpp 113 | 114 | FileCopyEx3.rc 115 | ) 116 | 117 | if(MSVC) 118 | 119 | set(FILECOPYEX_SOURCES ${FILECOPYEX_SOURCES} 120 | src/vc10wrapper.cpp 121 | plugin.def 122 | ) 123 | 124 | if(PLATFORM STREQUAL "Win32") 125 | 126 | FIND_PROGRAM (MASM_EXECUTABLE ml) 127 | # message("masm: ${MASM_EXECUTABLE}") 128 | set(ASM_OBJECTS) 129 | foreach(src vc10) 130 | set(ASM_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/${src}.asm) 131 | set(ASM_OBJECT ${CMAKE_CURRENT_BINARY_DIR}/${src}.obj) 132 | set(ASM_OBJECTS ${ASM_OBJECTS} ${ASM_OBJECT}) 133 | add_custom_command( 134 | OUTPUT ${ASM_OBJECT} 135 | COMMAND ${MASM_EXECUTABLE} 136 | ARGS /c /Fo ${ASM_OBJECT} ${ASM_SOURCE} 137 | DEPENDS ${ASM_SOURCE} 138 | ) 139 | endforeach(src) 140 | 141 | set(FILECOPYEX_SOURCES ${FILECOPYEX_SOURCES} 142 | src/vc10wrapper.cpp 143 | ${ASM_OBJECTS} 144 | ) 145 | 146 | endif() 147 | 148 | else() 149 | set(FILECOPYEX_SOURCES ${FILECOPYEX_SOURCES} 150 | plugin.gcc.def 151 | ) 152 | endif() 153 | 154 | #------------------------------------------------------------------------------- 155 | 156 | set(FILECOPYEX_LIBRARIES 157 | kernel32.lib 158 | user32.lib 159 | advapi32.lib 160 | Mpr.lib 161 | ) 162 | 163 | #if(MINGW) 164 | #set(FILECOPYEX_LIBRARIES "${FILECOPYEX_LIBRARIES} msvcr100" 165 | #) 166 | #endif() 167 | 168 | if(MSVC) 169 | 170 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") 171 | 172 | set(FILECOPYEX_LIBRARIES ${FILECOPYEX_LIBRARIES} 173 | libcmtd.lib 174 | libcpmtd.lib 175 | ) 176 | 177 | else() 178 | 179 | set(FILECOPYEX_LIBRARIES ${FILECOPYEX_LIBRARIES} 180 | libcmt.lib 181 | libcpmt.lib 182 | ) 183 | 184 | endif() 185 | 186 | endif() 187 | 188 | add_library(FileCopyEx3 SHARED ${FILECOPYEX_SOURCES}) 189 | 190 | set_target_properties(FileCopyEx3 191 | PROPERTIES 192 | COMPILE_FLAGS "${CMAKE_CXX_FLAGS}" 193 | LINK_FLAGS ${CMAKE_LINK_FLAGS} 194 | ) 195 | 196 | #------------------------------------------------------------------------------- 197 | 198 | string(REPLACE "/" "\\" BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}") 199 | message("BUILD_DIR: ${BUILD_DIR}") 200 | 201 | target_link_libraries(FileCopyEx3 ${FILECOPYEX_LIBRARIES}) 202 | 203 | string(REPLACE "/" "\\" OUTPUT_DIR ${OUTPUT_DIR}) 204 | string(REPLACE "/" "\\" DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/data") 205 | 206 | if(MSVC) 207 | 208 | add_custom_command(TARGET FileCopyEx3 209 | POST_BUILD 210 | COMMAND if not exist "${OUTPUT_DIR}" ( mkdir "${OUTPUT_DIR}" ) 211 | COMMAND cp -f -R --target-directory=${OUTPUT_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/data/* 212 | COMMAND cp -f --target-directory=${OUTPUT_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/changelog.txt 213 | COMMAND cp -f --target-directory=${OUTPUT_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt 214 | COMMAND cp -f --target-directory=${OUTPUT_DIR} FileCopyEx3.dll 215 | COMMAND if exist FileCopyEx3.pdb cp -f --target-directory=${OUTPUT_DIR} FileCopyEx3.pdb 216 | COMMAND if exist FileCopyEx3.map cp -f --target-directory=${OUTPUT_DIR} FileCopyEx3.map 217 | WORKING_DIRECTORY ${BUILD_DIR} 218 | VERBATIM 219 | ) 220 | 221 | else() 222 | 223 | add_custom_command(TARGET FileCopyEx3 224 | POST_BUILD 225 | COMMAND if not exist "${OUTPUT_DIR}" ( mkdir "${OUTPUT_DIR}" ) 226 | COMMAND if not exist "${OUTPUT_DIR}\\doc" ( mkdir "${OUTPUT_DIR}\\doc" ) 227 | COMMAND if not exist "${OUTPUT_DIR}\\resource" ( mkdir "${OUTPUT_DIR}\\resource" ) 228 | COMMAND copy /Y FileCopyEx3.dll ${OUTPUT_DIR}\\FileCopyEx3.dll 229 | COMMAND copy /Y ${DATA_DIR}\\*.hlf ${OUTPUT_DIR} 230 | COMMAND copy /Y ${DATA_DIR}\\*.lng ${OUTPUT_DIR} 231 | COMMAND copy /Y ${DATA_DIR}\\*.diz ${OUTPUT_DIR} 232 | # COMMAND copy /Y ${DATA_DIR}\\doc\\*.* ${OUTPUT_DIR}\\doc 233 | COMMAND copy /Y ${DATA_DIR}\\resource\\*.* ${OUTPUT_DIR}\\resource 234 | WORKING_DIRECTORY ${BUILD_DIR} 235 | VERBATIM 236 | ) 237 | 238 | endif() 239 | 240 | if(CMAKE_BUILD_TYPE STREQUAL "Release") 241 | 242 | add_custom_command(TARGET FileCopyEx3 243 | POST_BUILD 244 | DEPENDS ${BUILD_DIR}\\FileCopyEx3.dll 245 | COMMAND make_dist.cmd ${FAR_VERSION} ${CONF} 246 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 247 | VERBATIM 248 | ) 249 | 250 | endif() 251 | 252 | -------------------------------------------------------------------------------- /src/Engine.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #include "CopyProgress.h" 30 | #include "Tools.h" 31 | #include "Framework/FileNameStoreEnum.h" 32 | 33 | #define PARENTDIRECTORY L".." 34 | #define THISDIRECTORY L"." 35 | 36 | struct FileStruct 37 | { 38 | int64_t Size, Read, Written, ResumePos; 39 | FILETIME CreationTime, LastAccessTime, LastWriteTime; 40 | intptr_t RenameNum; 41 | TOverwriteMode OverMode; 42 | intptr_t Level; 43 | intptr_t PanelIndex; 44 | intptr_t SectorSize; 45 | DWORD Attr; 46 | DWORD Flags; 47 | }; 48 | 49 | struct BuffStruct 50 | { 51 | size_t NextPos, WritePos; 52 | intptr_t FileNumber; 53 | bool EndFlag; 54 | }; 55 | 56 | class TBuffInfo 57 | { 58 | public: 59 | int64_t OrgSize; 60 | size_t BuffSize; 61 | uint8_t * Buffer; 62 | BuffStruct * BuffInf; 63 | HANDLE OutFile; 64 | intptr_t OutNum; 65 | String SrcName, DstName; 66 | }; 67 | 68 | struct RememberStruct 69 | { 70 | int64_t Size; 71 | FILETIME creationTime, lastAccessTime, lastWriteTime; 72 | intptr_t Level; 73 | DWORD Attr, Flags; 74 | String Src, Dst; 75 | }; 76 | 77 | PluginPanelItem * GetPanelItem(HANDLE hPlugin, FILE_CONTROL_COMMANDS Command, intptr_t Param1); 78 | 79 | struct TPanelItem 80 | { 81 | public: 82 | TPanelItem(size_t idx, bool active = true, bool selected = false); 83 | ~TPanelItem() 84 | { 85 | delete[] ppi; 86 | } 87 | PluginPanelItem * operator->() const { return ppi; } 88 | protected: 89 | PluginPanelItem * ppi; 90 | }; 91 | 92 | class Engine 93 | { 94 | public: 95 | Engine(); 96 | 97 | enum MResult { MRES_NONE, MRES_OK, MRES_STDCOPY, MRES_STDCOPY_RET }; 98 | MResult Main(bool move, bool curonly); 99 | 100 | private: 101 | FileNameStore SrcNames, DstNames; 102 | std::vector Files; 103 | FileNameStoreEnum FlushSrc, FlushDst; 104 | bool Parallel, SkipNewer, SkippedToTemp; 105 | int Streams, Rights, 106 | CompressMode, EncryptMode; 107 | TOverwriteMode OverwriteMode; 108 | size_t BufSize; 109 | int64_t ReadSpeedLimit, WriteSpeedLimit; 110 | int ReadAlign; 111 | bool _CopyDescs, _ClearROFromCD, _DescsInDirs, _ConfirmBreak, 112 | _HideDescs, _UpdateRODescs, _InverseBars; 113 | int _PreallocMin, _UnbuffMin; 114 | bool copyCreationTime, copyLastAccessTime, copyLastWriteTime; 115 | bool Aborted, KeepFiles; 116 | intptr_t volatile LastFile, FileCount, CopyCount; 117 | int64_t volatile ReadCb, WriteCb, ReadTime, WriteTime, TotalBytes, 118 | ReadN, WriteN, TotalN, FirstWrite, StartTime; 119 | // int64_t _LastCheckEscape, _CheckEscapeInterval; 120 | 121 | TBuffInfo * wbuffInfo, * buffInfo; 122 | HANDLE BGThread, FlushEnd, UiFree; 123 | 124 | CopyProgress CopyProgressBox; 125 | FarProgress ScanFoldersProgressBox; 126 | size_t SectorSize; 127 | bool Move; 128 | 129 | void Copy(); 130 | bool InitBuf(TBuffInfo * buffInfo); 131 | void UninitBuf(TBuffInfo * buffInfo); 132 | void SwapBufs(TBuffInfo * src, TBuffInfo * dst); 133 | bool CheckEscape(bool ShowKeepFilesCheckBox = true); 134 | bool AskAbort(bool ShowKeepFilesCheckBox = true); 135 | bool FlushBuff(TBuffInfo * buffInfo); 136 | void CheckDstFileExists(TBuffInfo * buffInfo, intptr_t fnum, FileStruct & info, 137 | const String & SrcName, const bool TryToOpenDstFile, 138 | String & DstName); 139 | void BGFlush(); 140 | bool WaitForFlushEnd(); 141 | friend uint32_t __stdcall FlushThread(void * p); 142 | void FinalizeBuf(TBuffInfo * buffInfo); 143 | void ProcessDesc(intptr_t fnum); 144 | void ShowReadName(const String &); 145 | void ShowWriteName(const String &); 146 | void ShowProgress(int64_t, int64_t, int64_t, int64_t, int64_t, 147 | int64_t, int64_t, int64_t); 148 | int CheckOverwrite(intptr_t fnum, String & ren); 149 | static void Delay(int64_t, int64_t, volatile int64_t &, int64_t); 150 | 151 | TOverwriteMode CheckOverwrite(intptr_t, const String &, const String &, String &); 152 | TOverwriteMode CheckOverwrite2(intptr_t, const String &, const String &, String &); 153 | void CheckOverwrite3(intptr_t fnum, String & DstName, FileStruct & info, const String & SrcName); 154 | void SetOverwriteMode(intptr_t); 155 | bool AddFile(const String & _src, const String & _dst, DWORD Attr, int64_t Size, const FILETIME & creationTime, const FILETIME & lastAccessTime, const FILETIME & lastWriteTime, DWORD Flags, intptr_t Level, intptr_t PanelIndex = -1); 156 | bool AddFile(const String & Src, const String & Dst, WIN32_FIND_DATA & fd, DWORD Flags, intptr_t Level, intptr_t PanelIndex = -1); 157 | void AddFile2(const String & src, intptr_t Level, DWORD attr, const String & dst); 158 | void AddTopLevelDir(const String & dir, const String & dstmask, DWORD Flags, FileName::Direction d); 159 | static void RememberFile(const String & Src, const String & Dst, WIN32_FIND_DATA & fd, DWORD Flags, intptr_t Level, RememberStruct &); 160 | bool AddRemembered(RememberStruct &); 161 | bool DirStart(const String & dir, const String & dst); 162 | bool DirEnd(const String & dir, const String & dst); 163 | static String FindDescFile(const String & dir, intptr_t * idx = nullptr); 164 | static String FindDescFile(const String & dir, WIN32_FIND_DATA & fd, intptr_t * idx = nullptr); 165 | 166 | void SetFileTime(HANDLE h, FILETIME * creationTime, FILETIME * lastAccessTime, FILETIME * lastWriteTime); 167 | void SetFileSizeAndTime(const String & fn, int64_t size, FILETIME * creationTime, FILETIME * lastAccessTime, FILETIME * lastWriteTime); 168 | 169 | static void FarToWin32FindData( 170 | const TPanelItem & tpi, 171 | OUT WIN32_FIND_DATA & wfd 172 | ); 173 | String CurPathDesc; 174 | DWORD CurPathFlags, CurPathAddFlags; 175 | WIN32_FIND_DATA DescFindData; 176 | 177 | std::map errTypes; 178 | intptr_t EngineError(const String & s, const String & fn, int code, uint32_t & flg, 179 | const String & title = L"", const String & type_id = L""); 180 | void FWError2(const String & Msg); 181 | 182 | bool CheckFreeDiskSpace(int64_t TotalBytesToProcess, bool MoveMode, 183 | const String & srcpathstr, const String & dstpathstr); 184 | bool CheckFATRestrictions(const String & srcpathstr, const String & dstpathstr); 185 | MResult MainFinalize(PanelInfo & panel_info_active); 186 | }; 187 | -------------------------------------------------------------------------------- /src/FarPayload.h: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #include "Framework/Node.h" 28 | #include "Framework/Payload.h" 29 | #include "SDK/plugin.hpp" 30 | 31 | class FarDlgNode; 32 | class FarDialog; 33 | 34 | struct Attribute 35 | { 36 | const wchar_t * Name; 37 | uint64_t Flag; 38 | }; 39 | const Attribute & Attrib(uint32_t i); 40 | uint32_t AttribCount(); 41 | 42 | size_t lablen(FarDialogItem & item); 43 | 44 | void SetItemText(FarDialogItem & item, const String & text); 45 | void DestroyItemText(FarDialogItem & item); 46 | 47 | class FarDlgPayload : public Payload 48 | { 49 | public: 50 | FarDlgPayload(); 51 | ~FarDlgPayload(); 52 | 53 | virtual void init(const String & _name); 54 | 55 | virtual void InitItem(FarDialogItem & item); 56 | virtual void RetrieveProperties(HANDLE) {} 57 | virtual void BeforeAdd(FarDialogItem &) {} 58 | virtual void LoadState(PropertyMap & state) {} 59 | virtual void SaveState(PropertyMap & state) {} 60 | 61 | virtual void DefSize(intptr_t &, intptr_t &, intptr_t &); 62 | virtual void ClearDialogItem() { dialogItem = -1; } 63 | 64 | FarDialog * getDialog() { return dialog; } 65 | void setDialog(FarDialog * _dialog) { dialog = _dialog; } 66 | 67 | intptr_t getDialogItem() const { return dialogItem; } 68 | 69 | void AddToItems(std::vector& Items, std::vector& RetCodes, intptr_t curX, intptr_t curY, intptr_t curW); 70 | 71 | protected: 72 | virtual void preInitItem(FarDialogItem & item); 73 | virtual void realInitItem(FarDialogItem & item); 74 | 75 | FarDialog * dialog; 76 | intptr_t dialogItem; // should be int, we are using -1 77 | }; 78 | 79 | class FarDlgLinePayload : public FarDlgPayload 80 | { 81 | public: 82 | DEFINE_CLASS(L"FarDlgLine", FarDlgLinePayload) 83 | 84 | void realInitItem(FarDialogItem & item) 85 | { 86 | item.Type = DI_TEXT; 87 | item.Flags |= DIF_SEPARATOR | DIF_BOXCOLOR; 88 | } 89 | }; 90 | 91 | class FarDlgLabelPayload : public FarDlgPayload 92 | { 93 | public: 94 | DEFINE_CLASS(L"FarDlgLabel", FarDlgLabelPayload) 95 | 96 | protected: 97 | virtual void init(const String & _name) 98 | { 99 | FarDlgPayload::init(_name); 100 | addProperty(L"Shorten", 0); 101 | } 102 | 103 | void realInitItem(FarDialogItem & item) 104 | { 105 | item.Type = DI_TEXT; 106 | item.X2 = getProp(L"Shorten") ? (item.X1 - 1) : (item.X1 + lablen(item) - 1); 107 | } 108 | 109 | static void BeforeAdd(FarDialogItem & item, FarDlgNode & obj) 110 | { 111 | } 112 | }; 113 | 114 | class FarDlgButtonPayload : public FarDlgPayload 115 | { 116 | public: 117 | DEFINE_CLASS(L"FarDlgButton", FarDlgButtonPayload) 118 | 119 | protected: 120 | virtual void init(const String & _name) 121 | { 122 | FarDlgPayload::init(_name); 123 | addProperty(L"Default", 0); 124 | addProperty(L"Result", -1); 125 | } 126 | virtual void realInitItem(FarDialogItem & item) 127 | { 128 | item.Type = DI_BUTTON; 129 | item.X2 = item.X1 + lablen(item) + 4 - 1; 130 | if (getProp(L"Default")) 131 | { 132 | item.Flags |= DIF_DEFAULTBUTTON; 133 | } 134 | } 135 | }; 136 | 137 | class FarDlgPanelPayload : public FarDlgPayload 138 | { 139 | public: 140 | DEFINE_CLASS(L"FarDlgPanel", FarDlgPanelPayload) 141 | }; 142 | 143 | class FarDlgCheckboxPayload : public FarDlgPayload 144 | { 145 | public: 146 | DEFINE_CLASS(L"FarDlgCheckbox", FarDlgCheckboxPayload) 147 | 148 | protected: 149 | virtual void init(const String & _name) 150 | { 151 | FarDlgPayload::init(_name); 152 | addProperty(L"Selected", 0); 153 | } 154 | 155 | void realInitItem(FarDialogItem & item) 156 | { 157 | item.Type = DI_CHECKBOX; 158 | item.X2 = item.X1 + lablen(item) + 4 - 1; 159 | item.Selected = int(getProp(L"Selected")); 160 | } 161 | 162 | void RetrieveProperties(HANDLE dlg); 163 | 164 | void LoadState(PropertyMap & state) 165 | { 166 | getProp(L"Selected") = state[getName()]; 167 | } 168 | void SaveState(PropertyMap & state) 169 | { 170 | state[getName()] = getProp(L"Selected"); 171 | } 172 | }; 173 | 174 | class FarDlgRadioButtonPayload : public FarDlgCheckboxPayload 175 | { 176 | public: 177 | DEFINE_CLASS(L"FarDlgRadioButton", FarDlgRadioButtonPayload) 178 | 179 | protected: 180 | 181 | void realInitItem(FarDialogItem & item) 182 | { 183 | FarDlgCheckboxPayload::realInitItem(item); 184 | 185 | item.Type = DI_RADIOBUTTON; 186 | } 187 | }; 188 | 189 | class FarDlgEditPayload : public FarDlgPayload 190 | { 191 | public: 192 | DEFINE_CLASS(L"FarDlgEdit", FarDlgEditPayload) 193 | 194 | protected: 195 | wchar_t HistoryId[64]; 196 | 197 | virtual void init(const String & _name) 198 | { 199 | FarDlgPayload::init(_name); 200 | addProperty(L"HistoryId", L"FarFramework\\DefaultEditHistory"); 201 | addProperty(L"Width", 10); 202 | } 203 | 204 | void realInitItem(FarDialogItem & item); 205 | void RetrieveProperties(HANDLE dlg); 206 | void LoadState(PropertyMap & state) 207 | { 208 | getProp(L"Text") = state[getName()]; 209 | } 210 | 211 | void SaveState(PropertyMap & state) 212 | { 213 | state[getName()] = getProp(L"Text"); 214 | } 215 | 216 | void BeforeAdd(FarDialogItem & item) 217 | { 218 | if (getProp(L"History")) 219 | { 220 | item.X2--; 221 | } 222 | } 223 | }; 224 | 225 | class FarDlgComboboxPayload : public FarDlgPayload 226 | { 227 | public: 228 | DEFINE_CLASS(L"FarDlgCombobox", FarDlgComboboxPayload) 229 | 230 | FarDlgComboboxPayload() { list.StructSize = sizeof(list); list.ItemsNumber = 0; list.Items = nullptr; } 231 | virtual ~FarDlgComboboxPayload() { delete list.Items; } 232 | 233 | protected: 234 | FarList list; 235 | 236 | virtual void init(const String & _name) 237 | { 238 | FarDlgPayload::init(_name); 239 | addProperty(L"Width", 10); 240 | addProperty(L"Items", L""); 241 | } 242 | 243 | void realInitItem(FarDialogItem & item); 244 | void RetrieveProperties(HANDLE dlg); 245 | void LoadState(PropertyMap & state) 246 | { 247 | getProp(L"Text") = state[getName()]; 248 | } 249 | void SaveState(PropertyMap & state, FarDlgNode & obj) 250 | { 251 | state[getName()] = getProp(L"Text"); 252 | } 253 | static void BeforeAdd(FarDialogItem & item, FarDlgNode & obj) 254 | { 255 | item.X2--; 256 | } 257 | }; 258 | 259 | class FarDialogPayload : public FarDlgPayload 260 | { 261 | public: 262 | DEFINE_CLASS(L"FarDialog", FarDialogPayload) 263 | 264 | protected: 265 | virtual void init(const String & _name) 266 | { 267 | FarDlgPayload::init(_name); 268 | addProperty(L"HelpTopic", L"NoTopic"); 269 | addProperty(L"Title", L""); 270 | addProperty(L"Warning", 0); 271 | } 272 | }; 273 | 274 | void InitObjMgr(); 275 | void DoneObjMgr(); 276 | -------------------------------------------------------------------------------- /src/tools.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include "Framework/StdHdr.h" 26 | #include "Framework/FileUtils.h" 27 | #include "Common.h" 28 | #include "tools.h" 29 | 30 | // special HDD ID implementation for NT4 31 | #define HARDDISK_CONST_PART _T("\\Device\\Harddisk") 32 | #define HARDDISK_CONST_PART_LEN (_countof(HARDDISK_CONST_PART)-1) 33 | 34 | static bool GetDriveId(const String & path, String & res) 35 | { 36 | wchar_t buf[MAX_FILENAME]; 37 | if (WinNT4) 38 | { 39 | // special HDD ID implementation for NT4 40 | if (::QueryDosDevice(path.left(2).ptr(), buf, _countof(buf)) > 0) 41 | { 42 | String s = buf; 43 | String tmp = L"\\Device\\Harddisk"; 44 | if (!s.nicmp(tmp, tmp.len())) 45 | { 46 | res = s.substr(tmp.len(), 1); 47 | return true; 48 | } 49 | } 50 | } 51 | else if (::QueryDosDevice(path.left(2).ptr(), buf, _countof(buf)) > 0) 52 | { 53 | String s = buf; 54 | String tmp = L"\\Device\\HarddiskDmVolumes\\"; 55 | if (!s.nicmp(tmp, tmp.len())) 56 | { 57 | s = s.substr(tmp.len()); 58 | res = s.left(s.find('\\')); 59 | return true; 60 | } 61 | } 62 | return false; 63 | } 64 | 65 | static bool GetPhysDrive(const String & _path, int & res) 66 | { 67 | String path = _path; 68 | if (Win2K || WinXP) 69 | { 70 | if (path.left(11) != L"\\\\?\\Volume{") 71 | { 72 | wchar_t buf[MAX_FILENAME]; 73 | if (!::GetVolumeNameForVolumeMountPoint(path.ptr(), buf, _countof(buf))) 74 | return false; 75 | path = buf; 76 | } 77 | HANDLE hVolume = ::CreateFile(CutEndSlash(path).ptr(), 0, 78 | FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 79 | 0, nullptr); 80 | if (hVolume == INVALID_HANDLE_VALUE) 81 | return false; 82 | 83 | char outbuf[1024]; 84 | ::ZeroMemory(outbuf, sizeof(outbuf)); 85 | DWORD ret; 86 | if (::DeviceIoControl(hVolume, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, nullptr, 0, 87 | outbuf, _countof(outbuf), &ret, nullptr)) 88 | { 89 | VOLUME_DISK_EXTENTS * ext = (VOLUME_DISK_EXTENTS *)outbuf; 90 | res = ext->Extents[0].DiskNumber; 91 | ::CloseHandle(hVolume); 92 | return true; 93 | } 94 | ::CloseHandle(hVolume); 95 | } 96 | 97 | return false; 98 | } 99 | 100 | #if !defined(FILE_READ_ONLY_VOLUME) 101 | static int FILE_READ_ONLY_VOLUME = 0x00080000; 102 | #endif 103 | 104 | #if !defined(FILE_NAMED_STREAMS) 105 | static int FILE_NAMED_STREAMS = 0x00040000; 106 | #endif 107 | 108 | uint32_t VolFlags(const String & Path) 109 | { 110 | String path = Path; 111 | size_t sl = path.find_last_of(L"\\/"); 112 | size_t ml = path.find_first_of(L"*?"); 113 | if (ml != (size_t)-1 && ml < sl) 114 | return (uint32_t)-1; 115 | if (path.find_first_of(L"|<>") != (size_t)-1) 116 | return (uint32_t)-1; 117 | size_t cl = path.find(':'); 118 | if (cl != (size_t)-1 && (cl != 1 || cl != path.rfind(':') || 119 | (cl != path.len() - 1 && path.find_first_of(L"\\/") != 2))) 120 | return (uint32_t)-1; 121 | if (ml != (size_t)-1) 122 | path = ExtractFilePath(path); 123 | String root = GetFileRoot(path); 124 | 125 | DWORD clen, flg; 126 | wchar_t sysname[32]; 127 | if (::GetVolumeInformation(root.ptr(), nullptr, 0, nullptr, &clen, &flg, sysname, _countof(sysname))) 128 | { 129 | uint32_t res = 0; 130 | if (flg & FILE_FILE_COMPRESSION) 131 | res |= VF_COMPRESSION; 132 | if (flg & FILE_SUPPORTS_ENCRYPTION) 133 | res |= VF_ENCRYPTION; 134 | if (flg & FILE_PERSISTENT_ACLS) 135 | res |= VF_RIGHTS; 136 | if (flg & FILE_NAMED_STREAMS) 137 | res |= VF_STREAMS; 138 | // NT4 supports streams, but has no special flag for this fact 139 | if (!_wcsnicmp(sysname, L"FAT", 3)) 140 | res |= VF_FAT; 141 | else if (!_wcsicmp(sysname, L"NTFS")) 142 | res |= VF_STREAMS; 143 | if (flg & FILE_READ_ONLY_VOLUME) 144 | res |= VF_READONLY; 145 | if (flg & FILE_UNICODE_ON_DISK) 146 | res |= VF_UNICODE; 147 | if (GetDriveType(root.ptr()) == DRIVE_CDROM) 148 | res |= VF_CDROM; 149 | return res; 150 | } 151 | return (uint32_t)-1; 152 | } 153 | 154 | intptr_t CheckParallel(const String & _srcpath, const String & _dstpath) 155 | { 156 | String root1 = GetFileRoot(_srcpath); 157 | String root2 = GetFileRoot(_dstpath); 158 | int srctype = ::GetDriveType(root1.ptr()); 159 | int dsttype = ::GetDriveType(root2.ptr()); 160 | if (srctype != dsttype) 161 | return TRUE; 162 | if (!root1.icmp(root2)) 163 | return FALSE; 164 | 165 | if (srctype == DRIVE_REMOTE) 166 | return FALSE; 167 | else if (srctype == DRIVE_CDROM || srctype == DRIVE_REMOVABLE) 168 | return TRUE; 169 | else if (srctype == DRIVE_FIXED) 170 | { 171 | int drv1, drv2; 172 | if (GetPhysDrive(root1, drv1) && 173 | GetPhysDrive(root2, drv2)) 174 | { 175 | if (drv1 != drv2) 176 | return TRUE; 177 | else 178 | return FALSE; 179 | } 180 | String id1, id2; 181 | if (GetDriveId(root1, id1) && 182 | GetDriveId(root2, id2)) 183 | { 184 | if (id1.icmp(id2)) 185 | return TRUE; 186 | else 187 | return FALSE; 188 | } 189 | } 190 | 191 | return -1; 192 | } 193 | 194 | String DupName(const String & src, intptr_t n) 195 | { 196 | return ChangeFileExt(src, L"") + L"_" + String(n) + ExtractFileExt(src); 197 | } 198 | 199 | bool ExistsN(const String & fn, intptr_t n) 200 | { 201 | if (!n) 202 | return FileExists(fn); 203 | else 204 | return FileExists(DupName(fn, n)); 205 | } 206 | 207 | bool Newer(const FILETIME & ft1, const FILETIME & ft2) 208 | { 209 | return CompareFileTime(&ft1, &ft2) >= 0; 210 | } 211 | 212 | bool Newer(const String & fn1, const FILETIME & ft2) 213 | { 214 | WIN32_FIND_DATA fd; 215 | HANDLE hf = ::FindFirstFile(fn1.ptr(), &fd); 216 | if (hf != INVALID_HANDLE_VALUE) 217 | { 218 | ::FindClose(hf); 219 | return Newer(fd.ftLastWriteTime, ft2); 220 | } 221 | return FALSE; 222 | } 223 | 224 | bool RmDir(const String & fn) 225 | { 226 | String DirName = GetLongFileName(fn); 227 | DWORD attr = ::GetFileAttributes(DirName.ptr()); 228 | ::SetFileAttributes(DirName.ptr(), FILE_ATTRIBUTE_NORMAL); 229 | if (!::RemoveDirectory(DirName.ptr())) 230 | { 231 | ::SetFileAttributes(DirName.ptr(), attr); 232 | return false; 233 | } 234 | return true; 235 | } 236 | 237 | void DebugLog(const wchar_t * DebugMsg, ...) 238 | { 239 | wchar_t MsgBuf[1024]; 240 | va_list ArgPtr; 241 | va_start(ArgPtr, DebugMsg); 242 | _vsnwprintf_s(MsgBuf, _countof(MsgBuf), _countof(MsgBuf), DebugMsg, ArgPtr); 243 | va_end(ArgPtr); 244 | ::OutputDebugString(MsgBuf); 245 | } 246 | 247 | String ConvertPath(enum CONVERTPATHMODES mode, const String & src) 248 | { 249 | wchar_t fullName[MAX_PATH]; 250 | size_t size = FSF.ConvertPath(mode, src.c_str(), fullName, _countof(fullName)); 251 | if (size <= MAX_PATH) 252 | { 253 | String res(fullName); 254 | return res; 255 | } 256 | else 257 | { 258 | wchar_t * fullNameBuf = new wchar_t[size]; 259 | FSF.ConvertPath(mode, src.c_str(), fullNameBuf, size); 260 | String res(fullNameBuf); 261 | delete[] fullNameBuf; 262 | return res; 263 | } 264 | } 265 | -------------------------------------------------------------------------------- /data/resource/english.locd: -------------------------------------------------------------------------------- 1 | PluginName=File copy extended 2 | 3 | CopyDialog.Copy=Copy 4 | CopyDialog.Move=Move 5 | CopyDialog.CopyTo=Copy "%s" to: 6 | CopyDialog.MoveTo=Move "%s" to: 7 | CopyDialog.CopyFilesTo=Copy files to: 8 | CopyDialog.MoveFilesTo=Move files to: 9 | 10 | CopyDialog.Warning=Warning 11 | CopyDialog.Error=Error 12 | CopyDialog.WarnPrompt=Continue operation? 13 | CopyDialog.InvalidPath=Destination path is invalid 14 | CopyDialog.CompressWarn=Compression is not supported on destination volume 15 | CopyDialog.EncryptWarn=Encryption is not supported on destination volume 16 | CopyDialog.StreamsWarn=Streams are not supported on destination volume 17 | CopyDialog.RightsWarn=Access rights are not supported on destination volume 18 | CopyDialog.InvalidPathWarn=Destination path is incorrect 19 | CopyDialog.ReadOnlyWarn=Destination volume is read-only 20 | CopyDialog.DescSelectedWarn=You have selected a description file for copy/move operation. 21 | CopyDialog.DescSelectedWarn1=Do you want to copy/move it as ordinary file? 22 | CopyDialog.OntoItselfError=Cannot copy the file onto itself 23 | 24 | Status.ScanningFolders=Scanning folders... 25 | Status.FilesString=Files: 26 | Status.SizeString=Size: 27 | Status.CreatingList=Creating file list... 28 | Status.CreatingDirs=Creating directories... 29 | 30 | CopyDialog.Label1=Destination path: 31 | CopyDialog.ParallelCopy=Para&llel copy 32 | CopyDialog.SkipIfNewer=Copy ne&wer file(s) only 33 | CopyDialog.Label2=Existing files: 34 | CopyDialog.Ask=&Ask 35 | CopyDialog.Skip=&Skip 36 | CopyDialog.Overwrite=&Overwrite 37 | CopyDialog.Append=A&ppend 38 | CopyDialog.Rename=Auto &rename 39 | CopyDialog.Start=S&tart 40 | CopyDialog.Cancel=&Cancel 41 | CopyDialog.Settings=S&ettings... 42 | CopyDialog.Advanced=A&dvanced... 43 | 44 | AdvCopyDialog=Advanced settings 45 | AdvCopyDialog.SkippedToTemp=Put skipped files to temporar&y panel 46 | AdvCopyDialog.ResumeFiles=&Resume incomplete files 47 | AdvCopyDialog.Rights=Copy NTFS access ri&ghts 48 | AdvCopyDialog.Streams=Copy &NTFS streams 49 | AdvCopyDialog.creationTime=Copy creation time 50 | AdvCopyDialog.lastAccessTime=Copy last access time 51 | AdvCopyDialog.lastWriteTime=Copy modification time 52 | AdvCopyDialog.Compress=Co&mpression 53 | AdvCopyDialog.Encrypt=&Encryption 54 | AdvCopyDialog.ReadSpeedLimit="Limit re&ad speed to: " 55 | AdvCopyDialog.WriteSpeedLimit=Limit write spee&d to: 56 | AdvCopyDialog.Label3=Kb/s 57 | AdvCopyDialog.Label4=Kb/s 58 | AdvCopyDialog.Save=&Save 59 | AdvCopyDialog.OK=&OK 60 | AdvCopyDialog.Cancel=&Cancel 61 | 62 | SetupDialog=Settings 63 | SetupDialog.Label1=Buffer size: 64 | SetupDialog.BufPercent=% of &memory 65 | SetupDialog.BufSize=K&b 66 | SetupDialog.OverwriteDef=Over&write by default 67 | SetupDialog.CopyStreamsDef=Copy &streams by default 68 | SetupDialog.CopyRightsDef=Copy access ri&ghts by default 69 | SetupDialog.AllowParallel=Autodetect ¶llel copy 70 | SetupDialog.DefParallel=Use para&llel copy by default 71 | SetupDialog.CopyDescs=Copy &descriptions 72 | SetupDialog.DescsInSubdirs=Update descriptions in subd&irs 73 | SetupDialog.HideDescs=Make description &files hidden 74 | SetupDialog.ClearROFromCD=Clear &Read-only attribute from CD 75 | SetupDialog.ConnectLikeBars=Cha&nge direction of progress bars 76 | SetupDialog.Keys=Bind &hotkeys... 77 | SetupDialog.OK=&OK 78 | SetupDialog.Cancel=&Cancel 79 | SetupDialog.Sound=So&und... 80 | SetupDialog.About=About... 81 | SetupDialog.Label2=Preallocate d&isk space for files larger than 82 | ;SetupDialog.Label3=" larger than" 83 | SetupDialog.Label4=Kb 84 | SetupDialog.ConfirmBreak=Confirm te&rmination by ESC 85 | SetupDialog.ReadFilesOpenedForWriting=Re&ad files opened for writing 86 | SetupDialog.CheckFreeDiskSpace=Chec&k free disk space 87 | SetupDialog.Label5=Use unbu&ffered writing for files larger than 88 | ;SetupDialog.Label6=" larger than" 89 | SetupDialog.Label7=Kb 90 | 91 | KeysDialog=Hotkeys 92 | KeysDialog.BindToF5=Bind Extended copy to &F5/F6 93 | KeysDialog.Label1=Bind standard copy to: 94 | KeysDialog.AltShiftF5=&Alt-Shift-F5/F6 95 | KeysDialog.CtrlShiftF5=Ctrl-&Shift-F5/F6 96 | KeysDialog.CtrlAltF5=C&trl-Alt-F5/F6 97 | KeysDialog.OK=&OK 98 | KeysDialog.Cancel=&Cancel 99 | 100 | SoundDialog=Sound 101 | SoundDialog.Sound=&Beep after long operations 102 | SoundDialog.UseSystem=&System notification 103 | SoundDialog.UseBASS=Audio &file: 104 | SoundDialog.OK=&OK 105 | SoundDialog.Cancel=&Cancel 106 | SoundDialog.TestSound=&Test 107 | 108 | AboutDialog=About 109 | AboutDialog.Label1=File copy extended: plugin for FAR manager 110 | AboutDialog.Label2= 111 | AboutDialog.Label3=Idea & core (c) Max Antipin 112 | AboutDialog.Label4=Implementation (c) Serge Cheperis AKA craZZy 113 | AboutDialog.Label5=E-mail: crazzy@magnusoft.com 114 | AboutDialog.Label6=https://github.com/michaellukashov/filecopyex3/ 115 | AboutDialog.Label7=Fixes by slst [slst@mail333.com], Ivanych, 116 | AboutDialog.Label8=CDK, Nsky, Alter and Axxie [axxie@filecopyex.org.ua] 117 | AboutDialog.Label9=Support: slst and Axxie 118 | AboutDialog.Label10=Far2 + x64 version by djdron 119 | AboutDialog.Label11=Far3 version by Michael Lukashov (michael.lukashov@gmail.com) 120 | AboutDialog.Label12=Igor Yudintsev (igor.yudincev@gmail.com) 121 | AboutDialog.OK=&OK 122 | 123 | OverwriteDialog=Copy/Move 124 | OverwriteDialog.Label1=File already exists: 125 | OverwriteDialog.Label2= 126 | OverwriteDialog.Label3= 127 | OverwriteDialog.Label4= 128 | OverwriteDialog.AcceptForAll=&Accept choice for all files 129 | OverwriteDialog.SkipIfNewer=Copy only ne&wer files 130 | OverwriteDialog.SkippedToTemp=Place skipped files to &temporary panel 131 | OverwriteDialog.Overwrite=&Overwrite 132 | OverwriteDialog.Skip=&Skip 133 | OverwriteDialog.Append=A&ppend 134 | OverwriteDialog.Rename=&Rename 135 | OverwriteDialog.Cancel=&Cancel 136 | OverwriteDialog.Source=Source: 137 | OverwriteDialog.Destination=Existing: 138 | OverwriteDialog.Bytes=bytes 139 | 140 | RenameDialog=Rename 141 | RenameDialog.Label1=&New name: 142 | RenameDialog.OK=&OK 143 | RenameDialog.Cancel=&Cancel 144 | 145 | Menu.CopyFiles=&1. Copy files... 146 | Menu.MoveFiles=&2. Move files... 147 | Menu.CopyFilesUnderCursor=&3. Copy file under cursor... 148 | Menu.MoveFilesUnderCursor=&4. Move file under cursor... 149 | Menu.Config=&5. Settings... 150 | 151 | Error.MemAlloc=Memory allocation error 152 | Error.OutputFileCreate=Error creating output file 153 | Error.Write=Write error 154 | Error.FileDelete=File delete error 155 | Error.InputFileOpen=Error opening input file 156 | Error.Read=Read error 157 | Error.Encrypt=Error setting encryption attribute 158 | Error.Compress=Error setting compression attribute 159 | Error.FileOpen=File open error 160 | Error.ReadDesc=Error reading description file 161 | Error.WriteDesc=Error writing description file 162 | Error.DeleteDesc=Error deleting description file 163 | 164 | Engine.Reading=Reading: 165 | Engine.Writing=Writing: 166 | Engine.Copying=Copying 167 | Engine.Moving=Moving 168 | Engine.Total=Total: 169 | Engine.Elapsed=Elapsed: 170 | Engine.Remaining=Remaining: 171 | Engine.Of=of 172 | Engine.Bytes=b 173 | Engine.Kb=Kb 174 | Engine.Mb=Mb 175 | Engine.Gb=Gb 176 | Engine.Tb=Tb 177 | Engine.Pb=Pb 178 | Engine.Sec=s 179 | Engine.Copy=Copy 180 | Engine.Move=Move 181 | Engine.ReopenRetry=Reo&pen and retry 182 | 183 | Framework.Error=Error 184 | Framework.OK=&OK 185 | Framework.Retry=&Retry 186 | Framework.Skip=&Skip 187 | Framework.Abort=&Abort 188 | Framework.Yes=&Yes 189 | Framework.No=&No 190 | 191 | CopyError=Error 192 | CopyError.Yes=&Yes 193 | CopyError.No=&No 194 | CopyError.Retry=&Retry 195 | CopyError.Skip=&Skip 196 | CopyError.Abort=&Abort 197 | CopyError.KeepFiles=&Keep incomplete files 198 | CopyError.Reopen=Re&open file before retry 199 | CopyError.StopPrompt=Abort operation? 200 | CopyError.StopTitle=Confirm 201 | CopyError.SkipAll=Skip a&ll 202 | 203 | FreeSpaceErrorDialog.Title=Warning 204 | FreeSpaceErrorDialog.NotEnoughSpace=There is not enough space on disk 205 | FreeSpaceErrorDialog.AbortPrompt=Abort operation? 206 | FreeSpaceErrorDialog.AvailableSpace=Available space: 207 | FreeSpaceErrorDialog.RequiredSpace=Required space: 208 | FreeSpaceErrorDialog.Yes=&Yes 209 | FreeSpaceErrorDialog.No=&No 210 | 211 | FATErrorDialog.Title=Warning 212 | FATErrorDialog.Message=Cannot copy file "%s" on disk 213 | FATErrorDialog.AbortPrompt=Abort operation? 214 | FATErrorDialog.Yes=&Yes 215 | FATErrorDialog.No=&No 216 | -------------------------------------------------------------------------------- /src/FarPayload.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include "Framework/Node.h" 26 | #include "Framework/ObjectManager.h" 27 | #include "Framework/StringVector.h" 28 | #include "FarNode.h" 29 | #include "FarPayload.h" 30 | #include "Common.h" 31 | 32 | static const Attribute _Attrib[] = 33 | { 34 | // { L"SetColor", DIF_SETCOLOR }, 35 | { L"BoxColor", DIF_BOXCOLOR }, 36 | { L"Group", DIF_GROUP }, 37 | { L"LeftText", DIF_LEFTTEXT }, 38 | { L"MoveSelect", DIF_MOVESELECT }, 39 | { L"ShowAmpersand", DIF_SHOWAMPERSAND }, 40 | { L"CenterGroup", DIF_CENTERGROUP }, 41 | { L"NoBrackets", DIF_NOBRACKETS }, 42 | { L"Separator", DIF_SEPARATOR }, 43 | { L"Editor", DIF_EDITOR }, 44 | { L"History", DIF_HISTORY }, 45 | { L"EditExpand", DIF_EDITEXPAND }, 46 | { L"DropdownList", DIF_DROPDOWNLIST }, 47 | { L"UseLastHistory", DIF_USELASTHISTORY }, 48 | { L"BtnNoClose", DIF_BTNNOCLOSE }, 49 | { L"SelectOnEntry", DIF_SELECTONENTRY }, 50 | { L"NoFocus", DIF_NOFOCUS }, 51 | { L"MaskEdit", DIF_MASKEDIT }, 52 | { L"Disable", DIF_DISABLE }, 53 | { L"ListNoAmpersand", DIF_LISTNOAMPERSAND }, 54 | { L"ReadOnly", DIF_READONLY }, 55 | { L"3State", DIF_3STATE }, 56 | // { L"VarEdit", DIF_VAREDIT }, 57 | { L"Hidden", DIF_HIDDEN }, 58 | { L"ManualAddHistory", DIF_MANUALADDHISTORY }, 59 | }; 60 | const Attribute & Attrib(uint32_t i) { return _Attrib[i]; } 61 | uint32_t AttribCount() { return sizeof(_Attrib) / sizeof(Attribute); } 62 | 63 | void DestroyItemText(FarDialogItem & item) 64 | { 65 | delete[] item.Data; 66 | item.Data = nullptr; 67 | } 68 | 69 | void SetItemText(FarDialogItem & item, const String & text) 70 | { 71 | DestroyItemText(item); 72 | size_t len = text.len() + 1; 73 | wchar_t * t = new wchar_t[len]; 74 | text.copyTo(t, len); 75 | item.Data = t; 76 | item.MaxLength = 0; 77 | } 78 | 79 | FarDlgPayload::FarDlgPayload() 80 | { 81 | dialog = nullptr; 82 | dialogItem = -1; 83 | } 84 | 85 | FarDlgPayload::~FarDlgPayload() 86 | { 87 | } 88 | 89 | void FarDlgPayload::init(const String & _name) 90 | { 91 | Payload::init(_name); 92 | 93 | for (uint32_t Index = 0; Index < AttribCount(); Index++) 94 | { 95 | addProperty(Attrib(Index).Name, 0); 96 | } 97 | addProperty(L"FitWidth", 0); 98 | addProperty(L"Focus", 0); 99 | addProperty(L"NoBreak", 0); 100 | addProperty(L"Visible", 1); 101 | addProperty(L"Persistent", 0); 102 | addProperty(L"Text", L""); 103 | } 104 | 105 | void FarDlgPayload::preInitItem(FarDialogItem & item) 106 | { 107 | String p = getProp(L"Text"); 108 | if (p.empty()) 109 | { 110 | String n = getDialog()->getName() + L"." + getName(); 111 | String loc = LOC(n); 112 | p = (n == loc) ? L"" : loc; 113 | } 114 | SetItemText(item, p); 115 | 116 | for (uint32_t Index = 0; Index < AttribCount(); Index++) 117 | { 118 | if (getProp(Attrib(Index).Name)) 119 | { 120 | item.Flags |= Attrib(Index).Flag; 121 | } 122 | } 123 | if (getProp(L"Focus")) 124 | { 125 | item.Flags |= DIF_FOCUS; 126 | } 127 | } 128 | 129 | void FarDlgPayload::realInitItem(FarDialogItem & item) 130 | { 131 | } 132 | 133 | void FarDlgPayload::InitItem(FarDialogItem & item) 134 | { 135 | preInitItem(item); 136 | realInitItem(item); 137 | } 138 | 139 | void FarDlgPayload::DefSize(intptr_t & w, intptr_t & h, intptr_t & fit) 140 | { 141 | FarDialogItem item; 142 | ::ZeroMemory(&item, sizeof(item)); 143 | InitItem(item); 144 | fit = getProp(L"FitWidth").operator int(); 145 | w = item.X2 - item.X1 + 1; 146 | h = item.Y2 - item.Y1 + 1; 147 | DestroyItemText(item); 148 | } 149 | 150 | void FarDlgPayload::AddToItems(std::vector& Items, std::vector& RetCodes, intptr_t curX, intptr_t curY, intptr_t curW) 151 | { 152 | FarDialogItem item; 153 | ::ZeroMemory(&item, sizeof(item)); 154 | item.X1 = curX; 155 | item.Y1 = curY; 156 | item.Y2 = curY; 157 | InitItem(item); 158 | item.X2 = item.X1 + curW - 1; 159 | BeforeAdd(item); 160 | Items.push_back(item); 161 | dialogItem = Items.size() - 1; 162 | if (item.Type == DI_BUTTON && !(item.Flags & DIF_BTNNOCLOSE)) 163 | { 164 | int res = getProp(L"Result"); 165 | if (res != -1) 166 | { 167 | RetCode rc; 168 | rc.itemNo = Items.size() - 1; 169 | rc.retCode = res; 170 | RetCodes.push_back(rc); 171 | } 172 | } 173 | } 174 | 175 | void FarDlgCheckboxPayload::RetrieveProperties(HANDLE dlg) 176 | { 177 | getProp(L"Selected") = (int)Info.SendDlgMessage(dlg, DM_GETCHECK, dialogItem, 0); 178 | } 179 | 180 | void FarDlgEditPayload::realInitItem(FarDialogItem & item) 181 | { 182 | item.Type = DI_EDIT; 183 | int w = getProp(L"Width"); 184 | item.X2 = item.X1 + w - 1; 185 | if (item.Flags & DIF_HISTORY) 186 | { 187 | String p = getProp(L"HistoryId"); 188 | if (!p.empty()) 189 | { 190 | (String(L"FarFramework\\") + getDialog()->getName() + L"\\" + getName()).copyTo(HistoryId, _countof(HistoryId)); 191 | item.History = HistoryId; 192 | } 193 | } 194 | } 195 | 196 | static String GetDlgText(HANDLE dlg, intptr_t id) 197 | { 198 | FarDialogItemData item = { sizeof(FarDialogItemData) }; 199 | item.PtrLength = Info.SendDlgMessage(dlg, DM_GETTEXT, id, nullptr); 200 | item.PtrData = new wchar_t[item.PtrLength + 1]; 201 | Info.SendDlgMessage(dlg, DM_GETTEXT, id, &item); 202 | String t(item.PtrData); 203 | delete[] item.PtrData; 204 | return t; 205 | } 206 | 207 | void FarDlgEditPayload::RetrieveProperties(HANDLE dlg) 208 | { 209 | getProp(L"Text") = GetDlgText(dlg, dialogItem); 210 | } 211 | 212 | void FarDlgComboboxPayload::realInitItem(FarDialogItem & item) 213 | { 214 | item.Type = DI_COMBOBOX; 215 | int w = getProp(L"Width"); 216 | item.X2 = item.X1 + w - 1; 217 | 218 | item.ListItems = &list; 219 | if (list.Items) 220 | { 221 | delete list.Items; 222 | list.Items = nullptr; 223 | list.ItemsNumber = 0; 224 | } 225 | StringVector items; 226 | items.loadFromString(getProp(L"Items"), '\n'); 227 | if (items.Count()) 228 | { 229 | list.ItemsNumber = items.Count(); 230 | list.Items = new FarListItem[items.Count()]; 231 | for (size_t Index = 0; Index < items.Count(); Index++) 232 | { 233 | if (getProp(L"Text") == items[Index]) 234 | { 235 | list.Items[Index].Flags |= LIF_SELECTED; 236 | } 237 | } 238 | } 239 | } 240 | 241 | void FarDlgComboboxPayload::RetrieveProperties(HANDLE dlg) 242 | { 243 | getProp(L"Text") = GetDlgText(dlg, dialogItem); 244 | } 245 | 246 | size_t lablen(FarDialogItem & item) 247 | { 248 | if (item.Flags & DIF_SHOWAMPERSAND) 249 | { 250 | return wcslen(item.Data); 251 | } 252 | else 253 | { 254 | size_t res = 0; 255 | for (const wchar_t * p = item.Data; *p; p++) 256 | { 257 | if (*p != L'&') 258 | res++; 259 | } 260 | return res; 261 | } 262 | } 263 | 264 | void InitObjMgr() 265 | { 266 | objectManager = new ObjectManager; 267 | objectManager->regClass(L"FarDlgLine", &FarDlgLinePayload::create, &FarDlgNode::create); 268 | objectManager->regClass(L"FarDlgLabel", &FarDlgLabelPayload::create, &FarDlgNode::create); 269 | objectManager->regClass(L"FarDlgButton", &FarDlgButtonPayload::create, &FarDlgNode::create); 270 | objectManager->regClass(L"FarDlgCheckbox", &FarDlgCheckboxPayload::create, &FarDlgNode::create); 271 | objectManager->regClass(L"FarDlgRadioButton", &FarDlgRadioButtonPayload::create, &FarDlgNode::create); 272 | objectManager->regClass(L"FarDlgEdit", &FarDlgEditPayload::create, &FarDlgNode::create); 273 | objectManager->regClass(L"FarDlgCombobox", &FarDlgComboboxPayload::create, &FarDlgNode::create); 274 | 275 | objectManager->regClass(L"FarDlgPanel", &FarDlgPanelPayload::create, &FarDlgContainer::create); 276 | 277 | objectManager->regClass(L"FarDialog", &FarDialogPayload::create, &FarDialog::create); 278 | } 279 | 280 | void DoneObjMgr() 281 | { 282 | delete objectManager; 283 | } 284 | -------------------------------------------------------------------------------- /src/EngineTools.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include "Framework/StdHdr.h" 26 | #include "Framework/FileUtils.h" 27 | 28 | #include "Common.h" 29 | #include "FarPlugin.h" 30 | #include "EngineTools.h" 31 | #include "tools.h" 32 | #include "ui.h" 33 | 34 | void * Alloc(size_t size) 35 | { 36 | size = (size / DEFAULT_SECTOR_SIZE + 1) * DEFAULT_SECTOR_SIZE; 37 | return ::VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); 38 | } 39 | 40 | void Free(void * ptr) 41 | { 42 | ::VirtualFree(ptr, 0, MEM_RELEASE); 43 | } 44 | 45 | void FCompress(HANDLE handle, uint32_t flags) 46 | { 47 | if (flags == ATTR_INHERIT) 48 | return; 49 | USHORT b = flags ? 50 | COMPRESSION_FORMAT_DEFAULT : 51 | COMPRESSION_FORMAT_NONE; 52 | DWORD cb; 53 | if (!::DeviceIoControl(handle, FSCTL_SET_COMPRESSION, 54 | (LPVOID)&b, sizeof(b), nullptr, 0, &cb, nullptr)) 55 | Error(LOC(L"Error.Compress"), ::GetLastError()); 56 | } 57 | 58 | int FGetCompression(HANDLE handle) 59 | { 60 | USHORT res; 61 | DWORD cb; 62 | if (!::DeviceIoControl(handle, FSCTL_GET_COMPRESSION, 63 | nullptr, 0, &res, sizeof(res), &cb, nullptr)) 64 | return -1; 65 | else 66 | return res != COMPRESSION_FORMAT_NONE; 67 | } 68 | 69 | void FEncrypt(const String & fn, uint32_t flags) 70 | { 71 | if (!Win2K || flags == ATTR_INHERIT) 72 | return; 73 | BOOL res; 74 | ::SetFileAttributes(fn.ptr(), 0); 75 | if (flags) 76 | res = ::EncryptFile(fn.ptr()); 77 | else 78 | res = ::DecryptFile(fn.ptr(), 0); 79 | if (!res) 80 | Error2(LOC(L"Error.Encrypt"), fn, ::GetLastError()); 81 | } 82 | 83 | void FEncrypt(HANDLE handle, uint32_t flags) 84 | { 85 | if (!Win2K || flags == ATTR_INHERIT) 86 | return; 87 | DWORD cb; 88 | ENCRYPTION_BUFFER enc; 89 | enc.EncryptionOperation = flags ? 90 | FILE_SET_ENCRYPTION : 91 | FILE_CLEAR_ENCRYPTION; 92 | enc.Private[0] = 0; 93 | if (!::DeviceIoControl(handle, FSCTL_SET_ENCRYPTION, 94 | (LPVOID)&enc, sizeof(enc), nullptr, 0, &cb, nullptr)) 95 | Error(LOC(L"Error.Encrypt"), ::GetLastError()); 96 | } 97 | 98 | static void CopyACL2(const String & src, const String & dst, SECURITY_INFORMATION si) 99 | { 100 | const int bufSize = 16384; 101 | 102 | DWORD cb; 103 | PSECURITY_DESCRIPTOR secbuf = (PSECURITY_DESCRIPTOR)new char[bufSize]; 104 | BOOL res = ::GetFileSecurity(src.ptr(), si, secbuf, bufSize, &cb); 105 | if (res && cb) 106 | { 107 | delete[](char *)secbuf; 108 | secbuf = (PSECURITY_DESCRIPTOR)new char[cb]; 109 | res = ::GetFileSecurity(src.ptr(), si, secbuf, cb, &cb); 110 | } 111 | if (res) 112 | { 113 | ::SetFileSecurity(dst.ptr(), si, secbuf); 114 | } 115 | delete[](char *)secbuf; 116 | } 117 | 118 | int SACLPriv = 0; 119 | 120 | void FCopyACL(const String & src, const String & dst) 121 | { 122 | if (!SACLPriv) 123 | { 124 | HANDLE hToken; 125 | LUID luid; 126 | TOKEN_PRIVILEGES tkp; 127 | ::OpenProcessToken(GetCurrentProcess(), 128 | TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken); 129 | ::LookupPrivilegeValue(nullptr, SE_SECURITY_NAME, &luid); 130 | tkp.PrivilegeCount = 1; 131 | tkp.Privileges[0].Luid = luid; 132 | tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; 133 | ::AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(tkp), nullptr, nullptr); 134 | SACLPriv = 1; 135 | } 136 | CopyACL2(src, dst, DACL_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | OWNER_SECURITY_INFORMATION); 137 | CopyACL2(src, dst, SACL_SECURITY_INFORMATION); 138 | } 139 | 140 | HANDLE FOpen(const String & fn, DWORD mode, DWORD attr) 141 | { 142 | // new feature: ReadFilesOpenedForWriting checking (bug #17) 143 | DWORD dwShareMode = FILE_SHARE_READ; 144 | PropertyMap & Options = plugin->Options(); 145 | if ((mode & OPEN_READ) && (BOOL)(Options[L"ReadFilesOpenedForWriting"])) 146 | dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; 147 | String FileName = fn; 148 | if (!FileName.left(4).icmp(L"nul\\")) 149 | FileName = L"nul"; 150 | FileName = GetLongFileName(FileName); 151 | 152 | uint32_t f; 153 | if (mode & OPEN_READ) 154 | f = OPEN_EXISTING; 155 | else if (mode & OPEN_CREATE) 156 | f = CREATE_ALWAYS; 157 | else 158 | f = OPEN_ALWAYS; 159 | if (!(mode & OPEN_READ)) 160 | ::SetFileAttributes(fn.ptr(), FILE_ATTRIBUTE_NORMAL); 161 | 162 | HANDLE Handle = ::CreateFile( 163 | FileName.ptr(), 164 | // mode & OPEN_READ ? (GENERIC_READ) : (GENERIC_READ | GENERIC_WRITE), 165 | // fix #17 is partially rolled back: 166 | // Setting "compressed" attribute requires GENERIC_READ | GENERIC_WRITE 167 | // access mode during file write. 168 | mode & OPEN_READ ? (GENERIC_READ) : (GENERIC_READ | GENERIC_WRITE), 169 | // FILE_SHARE_READ | FILE_SHARE_WRITE | (WinNT ? FILE_SHARE_DELETE : 0), 170 | dwShareMode, 171 | nullptr, 172 | f, 173 | (mode & OPEN_BUF ? 0 : FILE_FLAG_NO_BUFFERING) | attr, 174 | nullptr); 175 | if (Handle == INVALID_HANDLE_VALUE) 176 | Handle = nullptr; 177 | if (Handle && (mode & OPEN_APPEND)) 178 | ::SetFilePointer(Handle, 0, nullptr, FILE_END); 179 | return Handle; 180 | } 181 | 182 | int64_t FSeek(HANDLE h, int64_t pos, int method) 183 | { 184 | LONG hi32 = HI32(pos); 185 | LONG lo32 = ::SetFilePointer(h, LO32(pos), &hi32, method); 186 | if (lo32 == INVALID_SET_FILE_POINTER && ::GetLastError()) 187 | return -1; 188 | else 189 | return MAKEINT64(lo32, hi32); 190 | } 191 | 192 | int64_t FTell(HANDLE h) 193 | { 194 | return FSeek(h, 0, FILE_CURRENT); 195 | } 196 | 197 | void SetFileSizeAndTime2(const String & fn, int64_t size, 198 | const FILETIME * creationTime, const FILETIME * lastAccessTime, 199 | const FILETIME * lastWriteTime) 200 | { 201 | HANDLE h = FOpen(fn, OPEN_WRITE_BUF, 0); 202 | if (!h) 203 | { 204 | Error2(LOC(L"Error.FileOpen"), fn, ::GetLastError()); 205 | } 206 | else 207 | { 208 | SetFileSizeAndTime2(h, size, creationTime, lastAccessTime, lastWriteTime); 209 | FClose(h); 210 | } 211 | } 212 | 213 | void SetFileSizeAndTime2(HANDLE h, int64_t size, const FILETIME * creationTime, 214 | const FILETIME * lastAccessTime, const FILETIME * lastWriteTime) 215 | { 216 | FSeek(h, size, FILE_BEGIN); 217 | ::SetEndOfFile(h); 218 | SetFileTime2(h, creationTime, lastAccessTime, lastWriteTime); 219 | } 220 | 221 | void SetFileTime2(const String & fn, const FILETIME * creationTime, 222 | const FILETIME * lastAccessTime, const FILETIME * lastWriteTime) 223 | { 224 | HANDLE h = FOpen(fn, OPEN_WRITE_BUF, 0); 225 | if (!h) 226 | { 227 | Error2(LOC(L"Error.FileOpen"), fn, ::GetLastError()); 228 | } 229 | else 230 | { 231 | SetFileTime2(h, creationTime, lastAccessTime, lastWriteTime); 232 | FClose(h); 233 | } 234 | } 235 | 236 | void SetFileTime2(HANDLE h, const FILETIME * creationTime, 237 | const FILETIME * lastAccessTime, const FILETIME * lastWriteTime) 238 | { 239 | ::SetFileTime(h, creationTime, lastAccessTime, lastWriteTime); 240 | } 241 | 242 | size_t FRead(HANDLE h, void * buf, size_t size) 243 | { 244 | ULONG res; 245 | if (!::ReadFile(h, buf, (DWORD)size, &res, nullptr)) 246 | return (size_t)-1; 247 | return res; 248 | } 249 | 250 | size_t FWrite(HANDLE h, const void * buf, size_t size) 251 | { 252 | ULONG res; 253 | if (!::WriteFile(h, buf, (DWORD)size, &res, nullptr)) 254 | return (size_t)-1; 255 | return res; 256 | } 257 | 258 | size_t GetSectorSize(const String & path) 259 | { 260 | DWORD x1, x2, x3, bps; 261 | if (::GetDiskFreeSpace( 262 | AddEndSlash(GetFileRoot(path)).ptr(), &x1, &bps, &x2, &x3)) 263 | return bps; 264 | else 265 | { 266 | //FWError(L"Warning: GetSectorSize failed"); 267 | return DEFAULT_SECTOR_SIZE; 268 | } 269 | } 270 | 271 | bool IsFAT(const String & Path) 272 | { 273 | bool Result = (VolFlags(Path) & VF_FAT) != 0; 274 | return Result; 275 | } 276 | -------------------------------------------------------------------------------- /src/FarNode.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include "Framework/StrUtils.h" 26 | #include "Framework/ObjString.h" 27 | #include "FarNode.h" 28 | #include "FarPayload.h" 29 | #include "Common.h" 30 | #include "guid.hpp" 31 | 32 | FarDlgNode::FarDlgNode(void) 33 | { 34 | } 35 | 36 | FarDlgNode::~FarDlgNode(void) 37 | { 38 | } 39 | 40 | void FarDlgNode::InitItem(FarDialogItem & item) 41 | { 42 | getPayload().InitItem(item); 43 | } 44 | 45 | void FarDlgNode::RetrieveProperties(HANDLE dlg) 46 | { 47 | getPayload().RetrieveProperties(dlg); 48 | } 49 | 50 | void FarDlgNode::BeforeAdd(FarDialogItem & item) 51 | { 52 | getPayload().BeforeAdd(item); 53 | } 54 | 55 | void FarDlgNode::LoadState(PropertyMap & state) 56 | { 57 | getPayload().LoadState(state); 58 | } 59 | 60 | void FarDlgNode::SaveState(PropertyMap & state) 61 | { 62 | getPayload().SaveState(state); 63 | } 64 | 65 | void FarDlgNode::AddToItems(std::vector& Items, std::vector& RetCodes, intptr_t curX, intptr_t curY, intptr_t curW) 66 | { 67 | getPayload().AddToItems(Items, RetCodes, curX, curY, curW); 68 | } 69 | 70 | void FarDlgNode::DefSize(intptr_t & w, intptr_t & h, intptr_t & fit) 71 | { 72 | getPayload().DefSize(w, h, fit); 73 | } 74 | 75 | void FarDlgNode::ClearDialogItem() 76 | { 77 | getPayload().ClearDialogItem(); 78 | } 79 | 80 | FarDlgNode * FarDlgNode::FindChild(const String & name) 81 | { 82 | if (getName() == name) 83 | return this; 84 | else 85 | return nullptr; 86 | } 87 | 88 | struct _group 89 | { 90 | intptr_t start, end, w, h, nfit; 91 | }; 92 | 93 | void FarDlgContainer::DefSize(intptr_t & sumw, intptr_t & sumh, intptr_t & fit) 94 | { 95 | sumw = sumh = 0; 96 | intptr_t groupw = 0; 97 | intptr_t grouph = 0; 98 | fit = getPayload()(L"FitWidth").operator int(); 99 | for (size_t Index = 0; Index < childs.size(); Index++) 100 | { 101 | FarDlgNode & obj = child(Index); 102 | if (obj(L"Visible")) 103 | { 104 | intptr_t w, h, f; 105 | obj.DefSize(w, h, f); 106 | groupw += w + 2; 107 | if (h > grouph) 108 | grouph = h; 109 | if (!obj(L"NoBreak")) 110 | { 111 | if (groupw - 2 > sumw) 112 | sumw = groupw - 2; 113 | sumh += grouph; 114 | groupw = grouph = 0; 115 | } 116 | } 117 | } 118 | } 119 | 120 | void FarDlgContainer::AddToItems(std::vector& Items, std::vector& RetCodes, intptr_t curX, intptr_t curY, intptr_t curW) 121 | { 122 | intptr_t sumw = 0; 123 | intptr_t sumh = 0; 124 | std::vector<_group> Groups; 125 | _group group; 126 | group.start = group.w = group.h = group.nfit = 0; 127 | for (size_t Index = 0; Index < childs.size(); Index++) 128 | { 129 | FarDlgNode & obj = child(Index); 130 | if (obj(L"Visible")) 131 | { 132 | intptr_t w, h, f; 133 | obj.DefSize(w, h, f); 134 | if (f) 135 | { 136 | group.nfit++; 137 | w = 0; 138 | } 139 | group.w += w + 2; 140 | if (h > group.h) 141 | group.h = h; 142 | if (!obj(L"NoBreak")) 143 | { 144 | group.w -= 2; 145 | if (group.w > sumw) 146 | sumw = group.w; 147 | // sumh+=group.h; 148 | group.end = Index; 149 | Groups.push_back(group); 150 | group.w = group.h = group.nfit = 0; 151 | group.start = Index + 1; 152 | } 153 | } 154 | } 155 | intptr_t x = curX; 156 | intptr_t y = curY; 157 | for (size_t j = 0; j < Groups.size(); j++) 158 | { 159 | for (intptr_t Index = Groups[j].start; Index <= Groups[j].end; Index++) 160 | { 161 | FarDlgNode & obj = child(Index); 162 | if (obj(L"Visible")) 163 | { 164 | intptr_t w, h, f; 165 | obj.DefSize(w, h, f); 166 | if (f) 167 | { 168 | w = (curW - Groups[j].w) / Groups[j].nfit; 169 | } 170 | obj.AddToItems(Items, RetCodes, x, y, w); 171 | x += w + 2; 172 | } 173 | } 174 | x = curX; 175 | y += Groups[j].h; 176 | } 177 | } 178 | 179 | void FarDlgContainer::LoadState(PropertyMap & state) 180 | { 181 | for (size_t Index = 0; Index < childs.size(); Index++) 182 | { 183 | if (child(Index).IsContainer() || (bool)child(Index)(L"Persistent")) 184 | { 185 | child(Index).LoadState(state); 186 | } 187 | } 188 | } 189 | 190 | void FarDlgContainer::SaveState(PropertyMap & state) 191 | { 192 | for (size_t Index = 0; Index < childs.size(); Index++) 193 | if (child(Index).IsContainer() || (bool)child(Index)(L"Persistent")) 194 | child(Index).SaveState(state); 195 | } 196 | 197 | void FarDlgContainer::RetrieveProperties(HANDLE dlg) 198 | { 199 | size_t cnt = childs.size(); 200 | for (size_t Index = 0; Index < cnt; Index++) 201 | { 202 | FarDlgNode & fdo = child(Index); 203 | if (fdo.getPayload().getDialogItem() != -1 || fdo.IsContainer()) 204 | fdo.RetrieveProperties(dlg); 205 | } 206 | } 207 | 208 | void FarDlgContainer::ClearDialogItems(std::vector& Items) 209 | { 210 | for (size_t Index = 0; Index < Items.size(); Index++) 211 | { 212 | DestroyItemText(Items[Index]); 213 | } 214 | for (size_t Index = 0; Index < childs.size(); Index++) 215 | { 216 | child(Index).ClearDialogItem(); 217 | } 218 | } 219 | 220 | FarDlgNode * FarDlgContainer::FindChild(const String & name) 221 | { 222 | if (getName() == name) 223 | return this; 224 | for (size_t Index = 0; Index < childs.size(); Index++) 225 | { 226 | FarDlgNode * obj = child(Index).FindChild(name); 227 | if (obj) 228 | return obj; 229 | } 230 | return nullptr; 231 | } 232 | 233 | void FarDlgNode::BeforeLoad() 234 | { 235 | getPayload().setDialog(Parent()->getPayload().getDialog()); 236 | } 237 | 238 | FarDialog::FarDialog() 239 | { 240 | } 241 | 242 | FarDialog::~FarDialog() 243 | { 244 | } 245 | 246 | intptr_t FarDialog::Execute() 247 | { 248 | std::vector Items; 249 | std::vector RetCodes; 250 | FarDialogItem frame; 251 | ::ZeroMemory(&frame, sizeof(frame)); 252 | frame.Type = DI_DOUBLEBOX; 253 | String p = (*this)(L"Title"); 254 | if (p.empty()) 255 | { 256 | p = LOC(getName()); 257 | } 258 | SetItemText(frame, p); 259 | Items.push_back(frame); 260 | 261 | intptr_t w, h, f; 262 | DefSize(w, h, f); 263 | AddToItems(Items, RetCodes, 5, 2, w); 264 | 265 | Items[0].X1 = 3; 266 | Items[0].Y1 = 1; 267 | Items[0].X2 = w + 6; 268 | Items[0].Y2 = h + 2; 269 | String HelpTopic = Property((*this)(L"HelpTopic")); 270 | 271 | HANDLE hnd = Info.DialogInit(&MainGuid, &MainGuid, -1, -1, w + 10, h + 4, 272 | HelpTopic.c_str(), 273 | Items.data(), Items.size(), 274 | 0, bool((*this)(L"Warning")) ? FDLG_WARNING : 0, 275 | Info.DefDlgProc, 0 276 | ); // !!! Need real Dialog GUID, instead of MainDialog 277 | intptr_t ret = -1; 278 | if (hnd != INVALID_HANDLE_VALUE) 279 | { 280 | intptr_t res = Info.DialogRun(hnd); 281 | for (size_t Index = 0; Index < RetCodes.size(); Index++) 282 | { 283 | if (RetCodes[Index].itemNo == res) 284 | { 285 | if (RetCodes[Index].retCode != -1) 286 | { 287 | RetrieveProperties(hnd); 288 | } 289 | ret = RetCodes[Index].retCode; 290 | break; 291 | } 292 | } 293 | Info.DialogFree(hnd); 294 | } 295 | ClearDialogItems(Items); 296 | return ret; 297 | } 298 | 299 | void FarDialog::BeforeLoad() 300 | { 301 | getPayload().setDialog(this); 302 | } 303 | 304 | void FarDialog::ResetControls() 305 | { 306 | ReloadPropertiesRecursive(); 307 | } 308 | 309 | FarDlgNode & FarDialog::operator[](const String & n) 310 | { 311 | FarDlgNode * obj = FindChild(n); 312 | if (!obj) 313 | FWError(Format(L"Request to undefined object %s", n.ptr())); 314 | return *obj; 315 | } 316 | -------------------------------------------------------------------------------- /src/CopyProgress.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include "Framework/StrUtils.h" 26 | #include "Common.h" 27 | #include "CopyProgress.h" 28 | #include "tools.h" 29 | #include "ui.h" 30 | 31 | const int W = 64, H = 13, MG = 5; 32 | 33 | CopyProgress::CopyProgress(void) 34 | { 35 | LastUpdate = LastUpdateRead = LastUpdateWrite = 0; 36 | Interval = TicksPerSec() / 10; 37 | CopyLastUpdate = 0; 38 | CopyInterval = TicksPerSec(); 39 | int w, h; 40 | GetConSize(w, h); 41 | X1 = (w - W + 1) / 2; 42 | Y1 = (h - H - 1) / 2; 43 | X2 = X1 + W - 1, Y2 = Y1 + H - 1; 44 | Move = false; 45 | } 46 | 47 | CopyProgress::~CopyProgress(void) 48 | { 49 | } 50 | 51 | void CopyProgress::Start(bool move) 52 | { 53 | Move = move; 54 | hScreen = Info.SaveScreen(0, 0, -1, -1); 55 | RedrawWindowIfNeeded(); 56 | } 57 | 58 | void CopyProgress::Stop() 59 | { 60 | Info.RestoreScreen(nullptr); 61 | Info.RestoreScreen(hScreen); 62 | } 63 | 64 | void CopyProgress::DrawTime(int64_t ReadBytes, int64_t WriteBytes, int64_t TotalBytes, 65 | int64_t ReadTime, int64_t WriteTime, 66 | int64_t ReadN, int64_t WriteN, int64_t TotalN, 67 | bool ParallelMode, int64_t FirstWriteTime, 68 | int64_t StartTime, size_t BufferSize) 69 | { 70 | RedrawWindowIfNeeded(); 71 | double TotalTime = 0; 72 | double ElapsedTime = (double)(GetTime() - StartTime); 73 | double RemainingTime = 0; 74 | 75 | //DebugLog(_T("RBytes: %I64d WBytes: %I64d RdTime: %I64d WrTime: %I64d StTime: %I64d\n"), 76 | // ReadBytes, WriteBytes, ReadTime, WriteTime, StartTime); 77 | 78 | const int64_t MinRWValue = 0x10000; 79 | 80 | if (((ReadBytes > MinRWValue) && (WriteBytes > MinRWValue)) || 81 | ((TotalBytes < (int64_t)BufferSize) && (ReadBytes > MinRWValue))) 82 | { 83 | double ReadSpeed = (ReadTime > 0) ? (double)ReadBytes / (double)ReadTime : 0; // bytes per tick 84 | double WriteSpeed = (WriteTime > 0) ? (double)WriteBytes / (double)WriteTime : 0; // bytes per tick 85 | 86 | double ReadTimeRemain = (ReadSpeed > 0.001) ? ((double)TotalBytes - (double)ReadBytes) / ReadSpeed : 0; 87 | double WriteTimeRemain = (WriteSpeed > 0.001) ? ((double)TotalBytes - (double)WriteBytes) / WriteSpeed : 0; 88 | 89 | //DebugLog(_T("RSpeed: %4.4f WSpeed: %4.4f RTRemain: %4.4f WTRemain: %4.4f\n"), 90 | // ReadSpeed, WriteSpeed, ReadTimeRemain, WriteTimeRemain); 91 | 92 | if (ParallelMode) 93 | { 94 | double BufferWriteTime = 0; 95 | if (ReadBytes == TotalBytes) 96 | BufferWriteTime = WriteTimeRemain; 97 | else 98 | BufferWriteTime = (WriteSpeed > 0.001) ? ((double)BufferSize / WriteSpeed) : 0; 99 | //DebugLog(_T("BufferWriteTime: %3.2f\n"), BufferWriteTime / TicksPerSec()); 100 | 101 | if (WriteSpeed > 0) 102 | { 103 | if (ReadSpeed < WriteSpeed) 104 | RemainingTime = ReadTimeRemain + BufferWriteTime; 105 | else 106 | RemainingTime = WriteTimeRemain + (double)FirstWriteTime; 107 | } 108 | else 109 | { 110 | RemainingTime = ReadTimeRemain + BufferWriteTime; 111 | } 112 | } 113 | else 114 | { 115 | // non-parallel mode 116 | RemainingTime = ReadTimeRemain + WriteTimeRemain; 117 | } 118 | 119 | TotalTime = ElapsedTime + RemainingTime; 120 | } 121 | 122 | if (TotalTime < 0) 123 | TotalTime = 0; 124 | if (ElapsedTime < 0) 125 | ElapsedTime = 0; 126 | if (RemainingTime < 0) 127 | RemainingTime = 0; 128 | 129 | TotalTime /= TicksPerSec(); 130 | ElapsedTime /= TicksPerSec(); 131 | RemainingTime /= TicksPerSec(); 132 | 133 | //DebugLog(_T("Total: %4.1f Elapsed: %4.1f Remain: %4.1f\n"), TotalTime, ElapsedTime, RemainingTime); 134 | //DebugLog(_T("---------------------------------------------------------------------------\n")); 135 | 136 | intptr_t l = X1 + MG; 137 | 138 | String buf; 139 | buf = LOC(L"Engine.Total"); 140 | Text(l, Y1 + 10, &clrLabel, buf); 141 | l += buf.len(); 142 | buf = Format(L" %2.2d:%2.2d ", (int)TotalTime / 60, (int)TotalTime % 60); 143 | Text(l, Y1 + 10, &clrText, buf); 144 | l += buf.len(); 145 | 146 | buf = LOC(L"Engine.Elapsed"); 147 | Text(l, Y1 + 10, &clrLabel, buf); 148 | l += buf.len(); 149 | buf = Format(L" %2.2d:%2.2d ", (int)ElapsedTime / 60, (int)ElapsedTime % 60); 150 | Text(l, Y1 + 10, &clrText, buf); 151 | 152 | String buf1; 153 | buf = String(L" ") + LOC(L"Engine.Remaining"); 154 | buf1 = Format(L" %2.2d:%2.2d", (int)RemainingTime / 60, (int)RemainingTime % 60); 155 | Text(X2 - MG - buf1.len() - buf.len() + 1, Y1 + 10, &clrLabel, buf); 156 | Text(X2 - MG - buf1.len() + 1, Y1 + 10, &clrText, buf1); 157 | 158 | int64_t tm = GetTime(); 159 | if (tm - CopyLastUpdate > CopyInterval) 160 | { 161 | CopyLastUpdate = tm; 162 | int pc = TotalBytes ? (int)((float)(ReadBytes + WriteBytes) / (TotalBytes * 2) * 100) : 0; 163 | if (pc < 0) 164 | pc = 0; 165 | if (pc > 100) 166 | pc = 100; 167 | buf = Format(L"{%d%% %2.2d:%2.2d} %s", pc, (int)RemainingTime / 60, (int)RemainingTime % 60, 168 | Move ? LOC(L"Engine.Moving").ptr() : LOC(L"Engine.Copying").ptr()); 169 | SetTitle2(buf); 170 | } 171 | } 172 | 173 | void CopyProgress::DrawProgress(const String & pfx, int y, int64_t cb, int64_t total, 174 | int64_t time, int64_t n, int64_t totaln) 175 | { 176 | if (cb > total) 177 | cb = total; 178 | Text(X1 + MG, Y1 + y, &clrLabel, pfx); 179 | String buf; 180 | buf = FormatWidth(FormatProgress(cb, total), W - MG * 2 - pfx.len()); 181 | Text(X1 + MG + pfx.len() + 1, Y1 + y, &clrText, buf); 182 | 183 | FarProgress::DrawProgress(X1 + MG, X2 - MG, Y1 + y + 1, total ? ((float)cb / total) : 0); 184 | 185 | int64_t rate = (int64_t)(time ? (float)cb / time * TicksPerSec() : 0); 186 | buf = FormatSpeed(rate); 187 | Text(X2 - MG - buf.len() + 1, Y1 + y, &clrText, buf); 188 | } 189 | 190 | void CopyProgress::DrawName(const String & fn, int y) 191 | { 192 | Text(X1 + MG, Y1 + y, &clrText, FormatWidth(fn, W - MG * 2)); 193 | } 194 | 195 | void CopyProgress::ShowReadName(const String & fn) 196 | { 197 | int64_t tm = GetTime(); 198 | if (tm - LastUpdateRead > Interval) 199 | { 200 | RedrawWindowIfNeeded(); 201 | LastUpdateRead = tm; 202 | DrawName(fn, 4); 203 | Info.Text(0, 0, 0, nullptr); 204 | } 205 | } 206 | 207 | void CopyProgress::ShowWriteName(const String & fn) 208 | { 209 | int64_t tm = GetTime(); 210 | if (tm - LastUpdateWrite > Interval) 211 | { 212 | RedrawWindowIfNeeded(); 213 | LastUpdateWrite = tm; 214 | DrawName(fn, 8); 215 | Info.Text(0, 0, 0, nullptr); 216 | } 217 | } 218 | 219 | void CopyProgress::ShowProgress(int64_t read, int64_t write, int64_t total, 220 | int64_t readTime, int64_t writeTime, 221 | int64_t readN, int64_t writeN, 222 | int64_t totalN, bool parallel, 223 | int64_t FirstWrite, int64_t StartTime, size_t BufferSize) 224 | { 225 | int64_t tm = GetTime(); 226 | if (tm - LastUpdate > Interval) 227 | { 228 | RedrawWindowIfNeeded(); 229 | LastUpdate = tm; 230 | DrawProgress(LOC(L"Engine.Reading"), 2, read, total, readTime, readN, totalN); 231 | DrawProgress(LOC(L"Engine.Writing"), 6, write, total, writeTime, writeN, totalN); 232 | DrawTime(read, write, total, readTime, writeTime, readN, writeN, totalN, 233 | parallel, FirstWrite, StartTime, BufferSize); 234 | Info.Text(0, 0, 0, nullptr); 235 | } 236 | } 237 | 238 | void CopyProgress::RedrawWindowIfNeeded() 239 | { 240 | if (NeedToRedraw) 241 | { 242 | RedrawWindow(); 243 | NeedToRedraw = false; 244 | } 245 | } 246 | 247 | void CopyProgress::RedrawWindow() 248 | { 249 | DrawWindow(X1, Y1, X2, Y2, Move ? LOC(L"Engine.Moving") : LOC(L"Engine.Copying")); 250 | wchar_t buf[512]; 251 | wchar_t * p = buf; 252 | for (int Index = 0; Index < W - MG * 2 + 2; Index++) 253 | *p++ = 0x2500; //'─' 254 | *p = 0; 255 | Info.Text(X1 + MG - 1, Y1 + 5, &clrFrame, buf); 256 | Info.Text(X1 + MG - 1, Y1 + 9, &clrFrame, buf); 257 | Info.Text(0, 0, 0, nullptr); 258 | Info.RestoreScreen(nullptr); 259 | TitleBuf = GetTitle(); 260 | } 261 | -------------------------------------------------------------------------------- /src/FarProgress.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | FileCopyEx - Extended File Copy plugin for Far 2 file manager 3 | 4 | Copyright (C) 2004 - 2010 5 | Idea & core: Max Antipin 6 | Coding: Serge Cheperis aka craZZy 7 | Bugfixes: slst, CDK, Ivanych, Alter, Axxie and Nsky 8 | Special thanks to Vitaliy Tsubin 9 | Far 2 (32 & 64 bit) full unicode version by djdron 10 | 11 | This program is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | This program is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with this program. If not, see . 23 | */ 24 | 25 | #include "Framework/StrUtils.h" 26 | #include "SDK/farcolor.hpp" 27 | #include "FarProgress.h" 28 | #include "Common.h" 29 | #include "ui.h" 30 | #include "tools.h" 31 | #include "guid.hpp" 32 | 33 | FarProgress::FarProgress(void) 34 | { 35 | Info.AdvControl(&MainGuid, ACTL_GETCOLOR, COL_DIALOGBOX, &clrFrame); 36 | Info.AdvControl(&MainGuid, ACTL_GETCOLOR, COL_DIALOGBOXTITLE, &clrTitle); 37 | Info.AdvControl(&MainGuid, ACTL_GETCOLOR, COL_DIALOGTEXT, &clrBar); 38 | Info.AdvControl(&MainGuid, ACTL_GETCOLOR, COL_DIALOGTEXT, &clrText); 39 | Info.AdvControl(&MainGuid, ACTL_GETCOLOR, COL_DIALOGTEXT, &clrLabel); // !!! not sure 40 | 41 | ProgX1 = 0; 42 | ProgX2 = 0; 43 | ProgY = 0; 44 | WinType = WIN_NONE; 45 | hScreen = 0; 46 | InverseBars = false; 47 | LastUpdate = 0; 48 | NeedToRedraw = false; 49 | } 50 | 51 | FarProgress::~FarProgress(void) 52 | { 53 | Hide(); 54 | } 55 | 56 | void FarProgress::DrawWindow(int X1, int Y1, int X2, int Y2, const String & caption) 57 | { 58 | int W = X2 - X1 + 1, H = Y2 - Y1 + 1; 59 | String tpl = caption; 60 | tpl += L"\n"; 61 | String bkg = String(' ', W - 10); 62 | bkg += L"\n"; 63 | for (int Index = 0; Index < H - 4; ++Index) 64 | { 65 | tpl += bkg; 66 | } 67 | Info.Message(&MainGuid, &ProgressDlg, FMSG_LEFTALIGN | FMSG_ALLINONE, nullptr, 68 | reinterpret_cast(tpl.ptr()), 0, 0); 69 | } 70 | 71 | void FarProgress::GetConSize(int & w, int & h) 72 | { 73 | HANDLE hc = ::GetStdHandle(STD_OUTPUT_HANDLE); 74 | CONSOLE_SCREEN_BUFFER_INFO bi; 75 | ::GetConsoleScreenBufferInfo(hc, &bi); 76 | w = bi.srWindow.Right - bi.srWindow.Left + 1; 77 | h = bi.srWindow.Bottom - bi.srWindow.Top + 1; 78 | } 79 | 80 | void FarProgress::ShowMessage(const String & msg) 81 | { 82 | Hide(); 83 | int sw, sh; 84 | GetConSize(sw, sh); 85 | int W = (int)msg.len() + 12, H = 5; 86 | int X1 = (sw - W + 1) / 2; 87 | int Y1 = (sh - H - 1) / 2; 88 | int X2 = X1 + W - 1, Y2 = Y1 + H - 1; 89 | hScreen = Info.SaveScreen(X1, Y1, X2 + 2, Y2 + 2); 90 | DrawWindow(X1, Y1, X2, Y2, L""); 91 | Info.Text(X1 + 6, Y1 + 2, &clrText, FormatWidth(msg, X2 - X1 - 11).ptr()); 92 | Info.Text(0, 0, 0, nullptr); 93 | WinType = WIN_MESSAGE; 94 | TitleBuf = GetTitle(); 95 | SetTitle2(msg); 96 | Info.RestoreScreen(nullptr); 97 | } 98 | 99 | void FarProgress::ShowProgress(const String & msg) 100 | { 101 | Hide(); 102 | int sw, sh; 103 | GetConSize(sw, sh); 104 | int W = sw / 2, H = 6; 105 | int X1 = (sw - W + 1) / 2; 106 | int Y1 = (sh - H - 1) / 2; 107 | int X2 = X1 + W - 1, Y2 = Y1 + H - 1; 108 | hScreen = Info.SaveScreen(X1, Y1, X2 + 2, Y2 + 2); 109 | DrawWindow(X1, Y1, X2, Y2, L""); 110 | Info.Text(X1 + 5, Y1 + 2, &clrText, FormatWidth(msg, X2 - X1 - 9).ptr()); 111 | ProgX1 = X1 + 5; 112 | ProgX2 = X2 - 5; 113 | ProgY = Y1 + 3; 114 | WinType = WIN_PROGRESS; 115 | SetPercent(0); 116 | DrawProgress(ProgX1, ProgX2, ProgY, 0); 117 | Info.Text(0, 0, 0, nullptr); 118 | TitleBuf = GetTitle(); 119 | ProgTitle = msg; 120 | SetTitle2(msg); 121 | Info.RestoreScreen(nullptr); 122 | } 123 | 124 | void FarProgress::DrawProgress(int x1, int x2, int y, float pc) 125 | { 126 | int n = x2 - x1 + 1; 127 | int fn = (int)(pc * n); 128 | int en = n - fn; 129 | wchar_t buf[512]; 130 | wchar_t * bp = buf; 131 | if (!InverseBars) 132 | { 133 | for (int Index = 0; Index < fn; Index++) 134 | *bp++ = 0x2588; //'█' 135 | for (int Index = 0; Index < en; Index++) 136 | *bp++ = 0x2591; //'░' 137 | } 138 | else 139 | { 140 | for (int Index = 0; Index < en; Index++) 141 | *bp++ = 0x2591; //'░' 142 | for (int Index = 0; Index < fn; Index++) 143 | *bp++ = 0x2588; //'█' 144 | } 145 | *bp = 0; 146 | Info.Text(x1, y, &clrText, buf); 147 | taskbarIcon.SetState(taskbarIcon.S_PROGRESS, pc); 148 | } 149 | 150 | void FarProgress::SetPercent(float pc) 151 | { 152 | if (WinType == WIN_PROGRESS) 153 | { 154 | if (GetTime() - LastUpdate > TicksPerSec() / 5) 155 | { 156 | DrawProgress(ProgX1, ProgX2, ProgY, pc); 157 | Info.Text(0, 0, 0, nullptr); 158 | SetTitle2(ProgTitle + L" {" + String((int)(pc * 100)) + L"%}"); 159 | LastUpdate = GetTime(); 160 | } 161 | } 162 | } 163 | 164 | void FarProgress::SetNeedToRedraw(bool Value) 165 | { 166 | NeedToRedraw = Value; 167 | } 168 | 169 | void FarProgress::Hide() 170 | { 171 | if (WinType != WIN_NONE) 172 | { 173 | Info.RestoreScreen(nullptr); 174 | Info.RestoreScreen(hScreen); 175 | SetTitle(TitleBuf); 176 | hScreen = 0; 177 | } 178 | WinType = WIN_NONE; 179 | taskbarIcon.SetState(taskbarIcon.S_NO_PROGRESS); 180 | } 181 | 182 | void FarProgress::Text(intptr_t x, intptr_t y, FarColor * c, const String & msg) 183 | { 184 | Info.Text(x, y, c, msg.ptr()); 185 | } 186 | 187 | void FarProgress::SetTitle(const String & v) 188 | { 189 | SetConsoleTitle(v.ptr()); 190 | } 191 | 192 | void FarProgress::SetTitle2(const String & v) const 193 | { 194 | String far_desc = TitleBuf; 195 | size_t x = far_desc.find('-'); 196 | if (x != (size_t)-1) 197 | far_desc = far_desc.substr(x); 198 | else 199 | far_desc = L"- Far"; 200 | SetTitle(v + L" " + far_desc); 201 | } 202 | 203 | String FarProgress::GetTitle() 204 | { 205 | wchar_t buf[512]; 206 | ::GetConsoleTitle(buf, _countof(buf)); 207 | return buf; 208 | } 209 | 210 | void FarProgress::ShowScanProgress(const String & msg) 211 | { 212 | Hide(); 213 | int ConsoleWidth; 214 | int ConsoleHeight; 215 | GetConSize(ConsoleWidth, ConsoleHeight); 216 | int WindowWidth = ConsoleWidth / 2; 217 | if (WindowWidth > 50) 218 | WindowWidth = 50; 219 | if (WindowWidth < 40) 220 | WindowWidth = 40; 221 | int WindowHeight = 7; 222 | int WindowCoordX1 = (ConsoleWidth - WindowWidth + 1) / 2; 223 | int WindowCoordY1 = (ConsoleHeight - WindowHeight - 1) / 2; 224 | int WindowCoordX2 = WindowCoordX1 + WindowWidth - 1; 225 | int WindowCoordY2 = WindowCoordY1 + WindowHeight - 1; 226 | hScreen = Info.SaveScreen(WindowCoordX1, WindowCoordY1, 227 | WindowCoordX2 + 2, WindowCoordY2 + 2); 228 | DrawWindow(WindowCoordX1, WindowCoordY1, WindowCoordX2, WindowCoordY2, L""); 229 | Info.Text(WindowCoordX1 + 5, WindowCoordY1 + 2, &clrText, 230 | FormatWidth(msg, WindowCoordX2 - WindowCoordX1 - 9).ptr()); 231 | ProgX1 = WindowCoordX1 + 5; 232 | ProgX2 = WindowCoordX2 - 5; 233 | ProgY = WindowCoordY1 + 3; 234 | WinType = WIN_SCAN_PROGRESS; 235 | DrawScanProgress(ProgX1, ProgX2, ProgY, 0, 0); 236 | Info.Text(0, 0, 0, nullptr); 237 | TitleBuf = GetTitle(); 238 | ProgTitle = msg; 239 | SetTitle2(msg); 240 | Info.RestoreScreen(nullptr); 241 | } 242 | 243 | void FarProgress::SetScanProgressInfo(int64_t NumberOfFiles, int64_t TotalSize) 244 | { 245 | if (WinType == WIN_SCAN_PROGRESS) 246 | { 247 | if (GetTime() - LastUpdate > TicksPerSec() / 5) 248 | { 249 | DrawScanProgress(ProgX1, ProgX2, ProgY, NumberOfFiles, TotalSize); 250 | Info.Text(0, 0, 0, nullptr); 251 | LastUpdate = GetTime(); 252 | } 253 | } 254 | } 255 | 256 | void FarProgress::DrawScanProgress(int x1, int x2, int y, int64_t NumberOfFiles, int64_t TotalSize) 257 | { 258 | String FilesFmtStr = LOC(L"Status.FilesString") + L" %-6I64d"; 259 | wchar_t FilesStr[256]; 260 | _snwprintf_s(FilesStr, _countof(FilesStr), _countof(FilesStr), (const wchar_t *)FilesFmtStr.ptr(), NumberOfFiles); 261 | 262 | String SizeFmtStr = LOC(L"Status.SizeString") + L" %s"; 263 | wchar_t SizeStr[256]; 264 | _snwprintf_s(SizeStr, _countof(SizeStr), _countof(SizeStr), (const wchar_t *)SizeFmtStr.ptr(), (const wchar_t *)FormatValue(TotalSize).ptr()); 265 | 266 | int s = x2 - x1 - (int)wcslen(SizeStr) - (int)wcslen(FilesStr); 267 | String spacer; 268 | if (s > 0) 269 | { 270 | spacer = String(' ', s); 271 | } 272 | else 273 | { 274 | SetNeedToRedraw(true); 275 | } 276 | 277 | wchar_t buf[256]; 278 | _snwprintf_s(buf, _countof(buf), _countof(buf), L"%s %s%s", FilesStr, spacer.ptr(), SizeStr); 279 | 280 | if ((int)wcslen(buf) > x2 - x1 + 2) 281 | { 282 | SetNeedToRedraw(true); 283 | } 284 | RedrawWindowIfNeeded(); 285 | 286 | Info.Text(x1, y + 1, &clrText, buf); 287 | taskbarIcon.SetState(taskbarIcon.S_WORKING); 288 | } 289 | 290 | void FarProgress::RedrawWindowIfNeeded() 291 | { 292 | if (NeedToRedraw) 293 | { 294 | NeedToRedraw = false; 295 | RedrawWindow(); 296 | } 297 | } 298 | 299 | void FarProgress::RedrawWindow() 300 | { 301 | ShowScanProgress(ProgTitle); 302 | } 303 | --------------------------------------------------------------------------------