Click here to Skip to main content
15,893,401 members
Articles / Desktop Programming / MFC

TCExplorer - Portable Software to Import, Export, Delete, Rename, View, Edit and Execute Files in TrueCrypt Containers

Rate me:
Please Sign up or sign in to vote.
4.71/5 (13 votes)
9 Oct 20079 min read 208.6K   2.5K   52  
A portable software to import, export, delete, rename, view, edit and execute files in TrueCrypt containers without requiring administrative privileges
/***************************************************************
 * Name:      TCList.h
 * Author:    Yap Chun Wei
 * Created:   2007-05-23
 * License:   Public domain
 **************************************************************/

#ifndef TCLIST_H
#define TCLIST_H

#include <wx/wxprec.h>

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif

#include "wx/listctrl.h"
#include "wx/filename.h"
#include "wx/stdpaths.h"
#include "wx/filefn.h"
#include "wx/dir.h"
#include "wx/progdlg.h"
#include "wx/ffile.h"
#include "wx/mimetype.h"
#include "wx/process.h"

#include <algorithm>
#include <set>
#include <map>
using namespace std;

#include "TCFile.h"
#include "TCDropSource.h"
#include "TCSupport.h"
#include "TCConfirmFileReplace.h"

struct OpenedFile
{
    wxString pathInTC_;
    wxString pathInTemp_;
    wxDateTime lastmodified_;
};

class TCList: public wxListCtrl
{
    friend class TCIDropSource;
    friend class TCDropSource;
    friend class TCDropTarget;

	public:
		TCList(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxListCtrlNameStr);
		virtual ~TCList();

		bool Open(LPCTSTR tcfile);  ///< Open a TrueCrypt container.
		void Close();               ///< Close TrueCrypt container.
        void RefreshList();         ///< Refresh contents of the current active directory of TrueCrypt container.
        void RefreshTCDetails();    ///< Refresh some details on the TrueCrypt container.
        void ShowDirectory(const wxString& dir);    ///< Show contents of TrueCrypt directory.
        void HandleTemporaryDirectory();            ///< Handle temporary system directory.
        void DeleteTemporaryDirectory();            ///< Delete temporary system directory.

		enum
		{
			idTCList = 5000,
			idContextView
		};

	private:
        void OnActivate(wxListEvent& event);    ///< Navigate directories.
        void OnSelect(wxListEvent& event);      ///< Select a directory/file.
        void OnExport(wxListEvent& event);      ///< Export directories/files.
        void OnKeyPress(wxListEvent& event);    ///< Refresh or Delete directories/files.
        void OnRename(wxListEvent& event);      ///< Rename a directory/file.
        void OnContext(wxContextMenuEvent& event);  ///< Context menu.
        void OnContextView(wxCommandEvent& event);  ///< View file in TrueCrypt container.
        void OnFocus(wxFocusEvent& event);      ///< TCExplorer becomes the focus.

    private: // Supporting functions.
        void Import(const wxArrayString& filenames); ///< Import directories/files.
        void Export();                               ///< Export directories and files to temporary system directory.
		bool ImportDirectory(wxString fromDir, const wxString& toTCDir); ///< Import directory and all its subdirectories and files.
        void ExportDirectory(const wxString& fromTCDir, const wxString& toDir); ///< Export directory and all its subdirectories and files.
        void DeleteDirectory(const wxString& TCDir);///< Delete directory and all its subdirectories and files.
		wxString GetCurrentActiveDirectory();       ///< Get current active directory (with terminating slash).
		void SetCurrentActiveDirectory(const wxString& path); ///< Set current active directory (with terminating slash).
		int CountSystemFiles(wxString sysDir);      ///< Count number of files under system directory (including subdirectories).
		int CountTCFiles(const wxString& TCDir);    ///< Count number of files under truecrypt directory (including subdirectories).
        void DeleteSystemDirectory(wxString sysDir);    ///< Delete system directory (including subdirectories).
        void SecureDeleteSystemDirectory(wxString sysDir);    ///< Securely delete system directory (including subdirectories).
        void EraserDeleteSystemDirectory(wxString sysDir);    ///< Securely delete system directory (including subdirectories) using Eraser.

    private: // Member variables.
		TCFile* tcFile_;
        vector<wxString> dirPaths_;     ///< Current active directory.
        set<wxString> directories_;     ///< Directories in current active directory.
        map<wxString,u32> files_;       ///< Files in current active directory.
        wxString curSelected_;          ///< Current selected file/directory.
        wxProgressDialog *progress_;    ///< Progress dialog for import, export and delete.
        int progressIndex_;             ///< Progress index for progress dialog.
        UINT64 totalBytesAvailable_;    ///< Total number of bytes available in TrueCrypt container.
        UINT64 totalBytesImported_;     ///< Total number of bytes imported.
        bool startDrag_;                ///< Drag and drop from TrueCrypt container has started.
        bool canDrop_;                  ///< Whether directories/files can be imported into TrueCrypt container.
        int confirmFileReplace_;        ///< -1 = No to all, 1 = Yes to all, 0 = Prompt user.
        TCConfirmFileReplace confirm_;  ///< Confirm File Replace dialog.
        vector<OpenedFile> openedFiles_; ///< Files which are currently opened in the temporary directory.
};

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Researcher
Singapore Singapore
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions