FileView plugin: Initial commit

This commit is contained in:
Brian Ferguson 2013-01-09 22:51:15 -07:00
parent 70dcad01b6
commit 15d6872b72
8 changed files with 1575 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,319 @@
/*
Copyright (C) 2012 Brian Ferguson
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "StdAfx.h"
enum MeasureType
{
TYPE_FOLDERPATH, // Current folder complete path
TYPE_FOLDERSIZE, // Current folder size
TYPE_FILECOUNT, // Number of files of current folder
TYPE_FOLDERCOUNT, // Number of sub-folders under the current folder
TYPE_FILENAME, // Name of file
TYPE_FILETYPE, // Type of file (ie "Text Document", not .txt)
TYPE_FILESIZE, // Size of file
TYPE_FILEDATE, // Date of file - Can be "Created Date", "Modified Date" etc.
TYPE_FILEPATH, // Full path of the file
TYPE_ICON // Icon of file
};
enum DateType
{
DTYPE_MODIFIED,
DTYPE_CREATED,
DTYPE_ACCESSED
};
enum SortType
{
STYPE_NAME,
STYPE_SIZE,
STYPE_TYPE,
STYPE_DATE
};
enum IconSize
{
IS_SMALL = 1, // 16x16
IS_MEDIUM = 0, // 32x32
IS_LARGE = 2, // 48x48
IS_EXLARGE = 4 // 256x256
};
struct FileInfo
{
std::wstring fileName;
std::wstring typeName; // File type description
std::wstring ext;
bool isFolder;
bool sortAscending; // Used for sorting function (since we cannot pass other values to a sort function)
UINT64 size;
FILETIME createdTime;
FILETIME modifiedTime;
FILETIME accessedTime;
FileInfo(): sortAscending(false)
{
Clear();
}
void Clear()
{
fileName = L"";
typeName = L"";
ext = L"";
isFolder = false;
size = 0;
createdTime.dwLowDateTime = 0;
createdTime.dwHighDateTime = 0;
modifiedTime.dwLowDateTime = 0;
modifiedTime.dwHighDateTime = 0;
accessedTime.dwLowDateTime = 0;
accessedTime.dwHighDateTime = 0;
}
};
struct ChildMeasure;
struct ParentMeasure
{
// Options from the .ini
std::wstring path;
std::wstring wildcardSearch;
SortType sortType;
DateType sortDateType;
int count;
bool isRecursive;
bool sortAscending;
bool showDotDot;
bool showFile;
bool showFolder;
bool showHidden;
bool showSystem;
bool hideExtension;
std::vector<std::wstring> extensions; // only show these extensions
// Internal values
std::vector<ChildMeasure*> children;
std::vector<FileInfo> files;
int fileCount;
int folderCount;
UINT64 folderSize;
bool needsUpdating;
bool needsIcons;
int indexOffset;
HANDLE thread;
// References and identifying values
void* skin;
LPCWSTR name;
ChildMeasure* ownerChild;
ParentMeasure() :
path(L""),
wildcardSearch(L""),
folderSize(0),
sortType(STYPE_NAME),
sortDateType(DTYPE_MODIFIED),
count(0),
sortAscending(true),
showDotDot(true),
showFile(true),
showFolder(true),
showHidden(true),
showSystem(false),
hideExtension(false),
extensions(),
children(NULL),
files(NULL),
skin(NULL),
name(L""),
ownerChild(NULL),
thread(NULL),
fileCount(0),
folderCount(0),
needsUpdating(true),
needsIcons(true),
indexOffset(0),
isRecursive(false) { }
};
struct ChildMeasure
{
// Options from the .ini
MeasureType type;
DateType date;
IconSize iconSize;
std::wstring iconPath;
int index;
bool ignoreCount;
bool needsIcon;
// Internal values
double value; // numerical value of the value (if available)
std::wstring strValue; // string value of the value
// References
ParentMeasure* parent;
ChildMeasure() :
type(TYPE_FOLDERPATH),
date(DTYPE_MODIFIED),
iconSize(IS_LARGE),
iconPath(L""),
index(0),
ignoreCount(false),
needsIcon(true),
value(0.0),
strValue(),
parent(NULL) { }
};
std::vector<std::wstring> Tokenize(const std::wstring& str, const std::wstring& delimiters)
{
std::vector<std::wstring> tokens;
std::wstring::size_type lastPos = str.find_first_not_of(delimiters, 0); // skip delimiters at beginning.
std::wstring::size_type pos = str.find_first_of(delimiters, lastPos); // find first "non-delimiter".
while (std::wstring::npos != pos || std::wstring::npos != lastPos)
{
tokens.push_back(str.substr(lastPos, pos - lastPos)); // found a token, add it to the vector.
lastPos = str.find_first_not_of(delimiters, pos); // skip delimiters. Note the "not_of"
pos = str.find_first_of(delimiters, lastPos); // find next "non-delimiter"
}
return tokens;
}
bool SortByName(const FileInfo& file1, const FileInfo& file2)
{
int sort = file1.sortAscending ? 1 : -1;
if (file1.isFolder && file2.isFolder)
{
return (sort * _wcsicmp(file1.fileName.c_str(), file2.fileName.c_str()) < 0);
}
else if (!file1.isFolder && !file2.isFolder)
{
return (sort * _wcsicmp(file1.fileName.c_str(), file2.fileName.c_str()) < 0);
}
return file1.isFolder;
}
bool SortByExtension(const FileInfo& file1, const FileInfo& file2)
{
int sort = file1.sortAscending ? 1 : -1;
if (file1.isFolder && file2.isFolder)
{
return (sort * _wcsicmp(file1.fileName.c_str(), file2.fileName.c_str()) < 0);
}
else if (!file1.isFolder && !file2.isFolder)
{
int result = (file1.ext.empty() && file2.ext.empty()) ? 0 : sort * _wcsicmp(file1.ext.c_str(), file2.ext.c_str());
return (0 != result) ? (result < 0) : (sort * _wcsicmp(file1.fileName.c_str(), file2.fileName.c_str()) < 0);
}
return file1.isFolder;
}
bool SortBySize(const FileInfo& file1, const FileInfo& file2)
{
int sort = file1.sortAscending ? 1 : -1;
if (file1.isFolder && file2.isFolder)
{
return (sort * _wcsicmp(file1.fileName.c_str(), file2.fileName.c_str()) < 0);
}
else if (!file1.isFolder && !file2.isFolder)
{
return (sort > 0) ? (file1.size < file2.size) : (file1.size > file2.size);
}
return file1.isFolder;
}
bool SortByAccessedTime(const FileInfo& file1, const FileInfo& file2)
{
int sort = file1.sortAscending ? 1 : -1;
if (file1.isFolder && file2.isFolder)
{
return (sort * CompareFileTime(&file1.accessedTime, &file2.accessedTime) < 0);
}
else if (!file1.isFolder && !file2.isFolder)
{
return (sort * CompareFileTime(&file1.accessedTime, &file2.accessedTime) < 0);
}
return file1.isFolder;
}
bool SortByCreatedTime(const FileInfo& file1, const FileInfo& file2)
{
int sort = file1.sortAscending ? 1 : -1;
if (file1.isFolder && file2.isFolder)
{
return (sort * CompareFileTime(&file1.createdTime, &file2.createdTime) < 0);
}
else if (!file1.isFolder && !file2.isFolder)
{
return (sort * CompareFileTime(&file1.createdTime, &file2.createdTime) < 0);
}
return file1.isFolder;
}
bool SortByModifiedTime(const FileInfo& file1, const FileInfo& file2)
{
int sort = file1.sortAscending ? 1 : -1;
if (file1.isFolder && file2.isFolder)
{
return (sort * CompareFileTime(&file1.modifiedTime, &file2.modifiedTime) < 0);
}
else if (!file1.isFolder && !file2.isFolder)
{
return (sort * CompareFileTime(&file1.modifiedTime, &file2.modifiedTime) < 0);
}
return file1.isFolder;
}
/*std::wstring UINT64_To_String(UINT64 value)
{
std::wstring result;
result.reserve(20); // Max of 20 digits possible
do
{
result += "0123456789"[value % 10];
value /= 10;
}
while(value);
std::reverse(result.begin(), result.end());
return result;
}*/

View File

@ -0,0 +1,43 @@
#define APSTUDIO_READONLY_SYMBOLS
#include <windows.h>
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,4,0
PRODUCTVERSION 2,3,0,1172
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileVersion", "1.0.4.0"
VALUE "LegalCopyright", "© 2012 - Brian Ferguson"
// Don't change the entries below!
VALUE "ProductName", "Rainmeter"
#ifdef _WIN64
VALUE "ProductVersion", "2.3.0.1172 (64-bit)"
#else
VALUE "ProductVersion", "2.3.0.1172 (32-bit)"
#endif //_WIN64
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>{64FDEE97-6B7E-40E5-A489-ECA322825BC8}</ProjectGuid>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<TargetName>FileView</TargetName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(SolutionDir)\Rainmeter.props" />
<Import Project="$(SolutionDir)\Plugins\Plugins.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>_USRDLL;PLUGINFILEVIEW_EXPORTS;HAVE_CONFIG_H;SUPPORT_UTF8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4018</DisableSpecificWarnings>
</ClCompile>
<Link>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PreprocessorDefinitions>_USRDLL;PLUGINFILEVIEW_EXPORTS;HAVE_CONFIG_H;SUPPORT_UTF8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4018</DisableSpecificWarnings>
</ClCompile>
<Link>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>_USRDLL;PLUGINFILEVIEW_EXPORTS;HAVE_CONFIG_H;SUPPORT_UTF8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4018</DisableSpecificWarnings>
</ClCompile>
<Link>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>_USRDLL;PLUGINFILEVIEW_EXPORTS;HAVE_CONFIG_H;SUPPORT_UTF8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4018</DisableSpecificWarnings>
</ClCompile>
<Link>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="PluginFileView.h" />
<ClInclude Include="StdAfx.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="PluginFileView.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="PluginFileView.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ResourceCompile Include="PluginFileView.rc" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="PluginFileView.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="PluginFileView.h" />
<ClInclude Include="StdAfx.h" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,37 @@
/*
Copyright (C) 2012 Brian Ferguson
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __STDAFX_H__
#define __STDAFX_H__
// WinAPI
#include <Windows.h>
#include <commctrl.h>
#include <commoncontrols.h>
#include <process.h>
// STL
#include <string>
#include <vector>
#include <list>
#include <algorithm>
// Rainmeter API
#include "../API/RainmeterAPI.h"
#endif

View File

@ -18,6 +18,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginAdvancedCPU", "Plugin
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginCoreTemp", "Plugins\PluginCoreTemp\PluginCoreTemp.vcxproj", "{F32FA418-8DF4-4E94-B92B-EBD502F5DC07}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginFileView", "Plugins\PluginFileView\PluginFileView.vcxproj", "{64FDEE97-6B7E-40E5-A489-ECA322825BC8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginFolderInfo", "Plugins\PluginFolderInfo\PluginFolderInfo.vcxproj", "{A221819D-4263-42AA-B22A-C022924842A7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginInputText", "Plugins\PluginInputText\PluginInputText.csproj", "{2CFEC79A-E39E-4FFD-ABC2-C4A69DD1E44D}"
@ -120,6 +122,14 @@ Global
{F32FA418-8DF4-4E94-B92B-EBD502F5DC07}.Release|Win32.Build.0 = Release|Win32
{F32FA418-8DF4-4E94-B92B-EBD502F5DC07}.Release|x64.ActiveCfg = Release|x64
{F32FA418-8DF4-4E94-B92B-EBD502F5DC07}.Release|x64.Build.0 = Release|x64
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Debug|Win32.ActiveCfg = Debug|Win32
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Debug|Win32.Build.0 = Debug|Win32
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Debug|x64.ActiveCfg = Debug|x64
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Debug|x64.Build.0 = Debug|x64
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Release|Win32.ActiveCfg = Release|Win32
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Release|Win32.Build.0 = Release|Win32
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Release|x64.ActiveCfg = Release|x64
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Release|x64.Build.0 = Release|x64
{A221819D-4263-42AA-B22A-C022924842A7}.Debug|Win32.ActiveCfg = Debug|Win32
{A221819D-4263-42AA-B22A-C022924842A7}.Debug|Win32.Build.0 = Debug|Win32
{A221819D-4263-42AA-B22A-C022924842A7}.Debug|x64.ActiveCfg = Debug|x64

View File

@ -1,4 +1,3 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Application", "Application\Application.vcxproj", "{D2A0903C-E760-4134-AE61-3D55BF8F760C}"
@ -16,6 +15,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginAdvancedCPU", "Plugin
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginCoreTemp", "Plugins\PluginCoreTemp\PluginCoreTemp.vcxproj", "{F32FA418-8DF4-4E94-B92B-EBD502F5DC07}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginFileView", "Plugins\PluginFileView\PluginFileView.vcxproj", "{64FDEE97-6B7E-40E5-A489-ECA322825BC8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginFolderInfo", "Plugins\PluginFolderInfo\PluginFolderInfo.vcxproj", "{A221819D-4263-42AA-B22A-C022924842A7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginiTunes", "Plugins\PluginiTunes\PluginiTunes.vcxproj", "{A2DD3CBE-B140-4892-A875-24107FA52518}"
@ -108,6 +109,14 @@ Global
{F32FA418-8DF4-4E94-B92B-EBD502F5DC07}.Release|Win32.Build.0 = Release|Win32
{F32FA418-8DF4-4E94-B92B-EBD502F5DC07}.Release|x64.ActiveCfg = Release|x64
{F32FA418-8DF4-4E94-B92B-EBD502F5DC07}.Release|x64.Build.0 = Release|x64
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Debug|Win32.ActiveCfg = Debug|Win32
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Debug|Win32.Build.0 = Debug|Win32
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Debug|x64.ActiveCfg = Debug|x64
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Debug|x64.Build.0 = Debug|x64
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Release|Win32.ActiveCfg = Release|Win32
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Release|Win32.Build.0 = Release|Win32
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Release|x64.ActiveCfg = Release|x64
{64FDEE97-6B7E-40E5-A489-ECA322825BC8}.Release|x64.Build.0 = Release|x64
{A221819D-4263-42AA-B22A-C022924842A7}.Debug|Win32.ActiveCfg = Debug|Win32
{A221819D-4263-42AA-B22A-C022924842A7}.Debug|Win32.Build.0 = Debug|Win32
{A221819D-4263-42AA-B22A-C022924842A7}.Debug|x64.ActiveCfg = Debug|x64