mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Fixed line endings and applied gitignore
This commit is contained in:
@ -1,194 +1,194 @@
|
||||
/*
|
||||
Copyright (C) 2010 Elestel
|
||||
|
||||
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 "FolderInfo.h"
|
||||
#include <windows.h>
|
||||
#include <list>
|
||||
#include "../API/RainmeterAPI.h"
|
||||
|
||||
#define UPDATE_TIME_MIN_MS 10000
|
||||
|
||||
CFolderInfo::CFolderInfo(void* ownerSkin) :
|
||||
m_InstanceCount(1),
|
||||
m_Skin(ownerSkin),
|
||||
m_IncludeSubFolders(false),
|
||||
m_IncludeHiddenFiles(false),
|
||||
m_IncludeSystemFiles(false),
|
||||
m_Size(),
|
||||
m_FileCount(),
|
||||
m_FolderCount(),
|
||||
m_RegExpFilter(),
|
||||
m_LastUpdateTime()
|
||||
{
|
||||
}
|
||||
|
||||
CFolderInfo::~CFolderInfo()
|
||||
{
|
||||
FreePcre();
|
||||
}
|
||||
|
||||
void CFolderInfo::AddInstance()
|
||||
{
|
||||
++m_InstanceCount;
|
||||
}
|
||||
|
||||
void CFolderInfo::RemoveInstance()
|
||||
{
|
||||
--m_InstanceCount;
|
||||
if (m_InstanceCount == 0)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
void CFolderInfo::Clear()
|
||||
{
|
||||
m_Size = 0;
|
||||
m_FileCount = 0;
|
||||
m_FolderCount = 0;
|
||||
}
|
||||
|
||||
void CFolderInfo::FreePcre()
|
||||
{
|
||||
if (m_RegExpFilter)
|
||||
{
|
||||
pcre_free(m_RegExpFilter);
|
||||
m_RegExpFilter = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CFolderInfo::Update()
|
||||
{
|
||||
DWORD now = GetTickCount();
|
||||
if (now - m_LastUpdateTime > UPDATE_TIME_MIN_MS)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (!m_Path.empty())
|
||||
{
|
||||
CalculateSize();
|
||||
}
|
||||
|
||||
m_LastUpdateTime = now;
|
||||
}
|
||||
}
|
||||
|
||||
void CFolderInfo::CalculateSize()
|
||||
{
|
||||
std::list<RawString> folderQueue;
|
||||
folderQueue.push_back(m_Path.c_str());
|
||||
|
||||
WCHAR searchPattern[MAX_PATH + 10];
|
||||
WCHAR buffer[MAX_PATH];
|
||||
char utf8Buf[MAX_PATH * 3];
|
||||
WIN32_FIND_DATA findData;
|
||||
HANDLE findHandle;
|
||||
while (!folderQueue.empty())
|
||||
{
|
||||
const RawString& ref = folderQueue.front();
|
||||
wsprintf(searchPattern, L"%s%s", ref.c_str(), L"\\*.*");
|
||||
|
||||
findHandle = FindFirstFile(searchPattern, &findData);
|
||||
if (INVALID_HANDLE_VALUE == findHandle)
|
||||
{
|
||||
folderQueue.pop_front();
|
||||
continue;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
// special case for "." and ".."
|
||||
if (wcscmp(findData.cFileName, L".") == 0 ||
|
||||
wcscmp(findData.cFileName, L"..") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool isFolder = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) > 0;
|
||||
|
||||
if (!m_IncludeHiddenFiles && (findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (!m_IncludeSystemFiles && (findData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (!isFolder && m_RegExpFilter)
|
||||
{
|
||||
const int utf8BufLen = WideCharToMultiByte(
|
||||
CP_UTF8, 0, findData.cFileName, (int)wcslen(findData.cFileName) + 1, utf8Buf, MAX_PATH * 3,
|
||||
nullptr, nullptr);
|
||||
if (0 != pcre_exec(m_RegExpFilter, nullptr, utf8Buf, utf8BufLen, 0, 0, nullptr, 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (isFolder)
|
||||
{
|
||||
m_FolderCount++;
|
||||
if (m_IncludeSubFolders)
|
||||
{
|
||||
wsprintf(buffer, L"%s\\%s", ref.c_str(), findData.cFileName);
|
||||
folderQueue.push_back(buffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_FileCount++;
|
||||
m_Size += ((UINT64)findData.nFileSizeHigh << 32) + findData.nFileSizeLow;
|
||||
}
|
||||
}
|
||||
while (FindNextFile(findHandle, &findData));
|
||||
FindClose(findHandle);
|
||||
|
||||
folderQueue.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
void CFolderInfo::SetPath(LPCWSTR path)
|
||||
{
|
||||
if (wcscmp(m_Path.c_str(), path) != 0)
|
||||
{
|
||||
m_Path = path;
|
||||
|
||||
// Force update next time
|
||||
m_LastUpdateTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CFolderInfo::SetRegExpFilter(LPCWSTR filter)
|
||||
{
|
||||
FreePcre();
|
||||
|
||||
if (*filter)
|
||||
{
|
||||
const int filterLen = (int)wcslen(filter) + 1;
|
||||
int bufLen = WideCharToMultiByte(CP_UTF8, 0, filter, filterLen, nullptr, 0, nullptr, nullptr);
|
||||
|
||||
char* buf = new char[bufLen];
|
||||
WideCharToMultiByte(CP_UTF8, 0, filter, filterLen, buf, bufLen, nullptr, nullptr);
|
||||
|
||||
const char* error;
|
||||
int erroffset;
|
||||
m_RegExpFilter = pcre_compile(buf, PCRE_UTF8, &error, &erroffset, nullptr);
|
||||
|
||||
delete [] buf;
|
||||
}
|
||||
}
|
||||
/*
|
||||
Copyright (C) 2010 Elestel
|
||||
|
||||
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 "FolderInfo.h"
|
||||
#include <windows.h>
|
||||
#include <list>
|
||||
#include "../API/RainmeterAPI.h"
|
||||
|
||||
#define UPDATE_TIME_MIN_MS 10000
|
||||
|
||||
CFolderInfo::CFolderInfo(void* ownerSkin) :
|
||||
m_InstanceCount(1),
|
||||
m_Skin(ownerSkin),
|
||||
m_IncludeSubFolders(false),
|
||||
m_IncludeHiddenFiles(false),
|
||||
m_IncludeSystemFiles(false),
|
||||
m_Size(),
|
||||
m_FileCount(),
|
||||
m_FolderCount(),
|
||||
m_RegExpFilter(),
|
||||
m_LastUpdateTime()
|
||||
{
|
||||
}
|
||||
|
||||
CFolderInfo::~CFolderInfo()
|
||||
{
|
||||
FreePcre();
|
||||
}
|
||||
|
||||
void CFolderInfo::AddInstance()
|
||||
{
|
||||
++m_InstanceCount;
|
||||
}
|
||||
|
||||
void CFolderInfo::RemoveInstance()
|
||||
{
|
||||
--m_InstanceCount;
|
||||
if (m_InstanceCount == 0)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
void CFolderInfo::Clear()
|
||||
{
|
||||
m_Size = 0;
|
||||
m_FileCount = 0;
|
||||
m_FolderCount = 0;
|
||||
}
|
||||
|
||||
void CFolderInfo::FreePcre()
|
||||
{
|
||||
if (m_RegExpFilter)
|
||||
{
|
||||
pcre_free(m_RegExpFilter);
|
||||
m_RegExpFilter = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CFolderInfo::Update()
|
||||
{
|
||||
DWORD now = GetTickCount();
|
||||
if (now - m_LastUpdateTime > UPDATE_TIME_MIN_MS)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (!m_Path.empty())
|
||||
{
|
||||
CalculateSize();
|
||||
}
|
||||
|
||||
m_LastUpdateTime = now;
|
||||
}
|
||||
}
|
||||
|
||||
void CFolderInfo::CalculateSize()
|
||||
{
|
||||
std::list<RawString> folderQueue;
|
||||
folderQueue.push_back(m_Path.c_str());
|
||||
|
||||
WCHAR searchPattern[MAX_PATH + 10];
|
||||
WCHAR buffer[MAX_PATH];
|
||||
char utf8Buf[MAX_PATH * 3];
|
||||
WIN32_FIND_DATA findData;
|
||||
HANDLE findHandle;
|
||||
while (!folderQueue.empty())
|
||||
{
|
||||
const RawString& ref = folderQueue.front();
|
||||
wsprintf(searchPattern, L"%s%s", ref.c_str(), L"\\*.*");
|
||||
|
||||
findHandle = FindFirstFile(searchPattern, &findData);
|
||||
if (INVALID_HANDLE_VALUE == findHandle)
|
||||
{
|
||||
folderQueue.pop_front();
|
||||
continue;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
// special case for "." and ".."
|
||||
if (wcscmp(findData.cFileName, L".") == 0 ||
|
||||
wcscmp(findData.cFileName, L"..") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool isFolder = (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) > 0;
|
||||
|
||||
if (!m_IncludeHiddenFiles && (findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (!m_IncludeSystemFiles && (findData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (!isFolder && m_RegExpFilter)
|
||||
{
|
||||
const int utf8BufLen = WideCharToMultiByte(
|
||||
CP_UTF8, 0, findData.cFileName, (int)wcslen(findData.cFileName) + 1, utf8Buf, MAX_PATH * 3,
|
||||
nullptr, nullptr);
|
||||
if (0 != pcre_exec(m_RegExpFilter, nullptr, utf8Buf, utf8BufLen, 0, 0, nullptr, 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (isFolder)
|
||||
{
|
||||
m_FolderCount++;
|
||||
if (m_IncludeSubFolders)
|
||||
{
|
||||
wsprintf(buffer, L"%s\\%s", ref.c_str(), findData.cFileName);
|
||||
folderQueue.push_back(buffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_FileCount++;
|
||||
m_Size += ((UINT64)findData.nFileSizeHigh << 32) + findData.nFileSizeLow;
|
||||
}
|
||||
}
|
||||
while (FindNextFile(findHandle, &findData));
|
||||
FindClose(findHandle);
|
||||
|
||||
folderQueue.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
void CFolderInfo::SetPath(LPCWSTR path)
|
||||
{
|
||||
if (wcscmp(m_Path.c_str(), path) != 0)
|
||||
{
|
||||
m_Path = path;
|
||||
|
||||
// Force update next time
|
||||
m_LastUpdateTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CFolderInfo::SetRegExpFilter(LPCWSTR filter)
|
||||
{
|
||||
FreePcre();
|
||||
|
||||
if (*filter)
|
||||
{
|
||||
const int filterLen = (int)wcslen(filter) + 1;
|
||||
int bufLen = WideCharToMultiByte(CP_UTF8, 0, filter, filterLen, nullptr, 0, nullptr, nullptr);
|
||||
|
||||
char* buf = new char[bufLen];
|
||||
WideCharToMultiByte(CP_UTF8, 0, filter, filterLen, buf, bufLen, nullptr, nullptr);
|
||||
|
||||
const char* error;
|
||||
int erroffset;
|
||||
m_RegExpFilter = pcre_compile(buf, PCRE_UTF8, &error, &erroffset, nullptr);
|
||||
|
||||
delete [] buf;
|
||||
}
|
||||
}
|
||||
|
@ -1,68 +1,68 @@
|
||||
/*
|
||||
Copyright (C) 2010 Elestel
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
#include "../../Common/RawString.h"
|
||||
#include "../../Library/pcre-8.10/config.h"
|
||||
#include "../../Library/pcre-8.10/pcre.h"
|
||||
|
||||
class CFolderInfo
|
||||
{
|
||||
public:
|
||||
CFolderInfo(void* ownerSkin);
|
||||
~CFolderInfo();
|
||||
|
||||
void AddInstance();
|
||||
void RemoveInstance();
|
||||
|
||||
void* GetSkin() { return m_Skin; }
|
||||
DWORD GetLastUpdateTime() { return m_LastUpdateTime; }
|
||||
|
||||
void SetPath(LPCWSTR path);
|
||||
void SetRegExpFilter(LPCWSTR filter);
|
||||
void SetSubFolders(bool flag) { m_IncludeSubFolders = flag; }
|
||||
void SetHiddenFiles(bool flag) { m_IncludeHiddenFiles = flag; }
|
||||
void SetSystemFiles(bool flag) { m_IncludeSystemFiles = flag; }
|
||||
|
||||
UINT64 GetSize() { return m_Size; }
|
||||
int GetFileCount() { return m_FileCount; }
|
||||
int GetFolderCount() { return m_FolderCount; }
|
||||
|
||||
void Update();
|
||||
|
||||
private:
|
||||
void Clear();
|
||||
void FreePcre();
|
||||
void CalculateSize();
|
||||
|
||||
UINT m_InstanceCount;
|
||||
void* m_Skin;
|
||||
|
||||
RawString m_Path;
|
||||
bool m_IncludeSubFolders;
|
||||
bool m_IncludeHiddenFiles;
|
||||
bool m_IncludeSystemFiles;
|
||||
UINT64 m_Size;
|
||||
UINT m_FileCount;
|
||||
UINT m_FolderCount;
|
||||
pcre* m_RegExpFilter;
|
||||
DWORD m_LastUpdateTime;
|
||||
};
|
||||
/*
|
||||
Copyright (C) 2010 Elestel
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
#include "../../Common/RawString.h"
|
||||
#include "../../Library/pcre-8.10/config.h"
|
||||
#include "../../Library/pcre-8.10/pcre.h"
|
||||
|
||||
class CFolderInfo
|
||||
{
|
||||
public:
|
||||
CFolderInfo(void* ownerSkin);
|
||||
~CFolderInfo();
|
||||
|
||||
void AddInstance();
|
||||
void RemoveInstance();
|
||||
|
||||
void* GetSkin() { return m_Skin; }
|
||||
DWORD GetLastUpdateTime() { return m_LastUpdateTime; }
|
||||
|
||||
void SetPath(LPCWSTR path);
|
||||
void SetRegExpFilter(LPCWSTR filter);
|
||||
void SetSubFolders(bool flag) { m_IncludeSubFolders = flag; }
|
||||
void SetHiddenFiles(bool flag) { m_IncludeHiddenFiles = flag; }
|
||||
void SetSystemFiles(bool flag) { m_IncludeSystemFiles = flag; }
|
||||
|
||||
UINT64 GetSize() { return m_Size; }
|
||||
int GetFileCount() { return m_FileCount; }
|
||||
int GetFolderCount() { return m_FolderCount; }
|
||||
|
||||
void Update();
|
||||
|
||||
private:
|
||||
void Clear();
|
||||
void FreePcre();
|
||||
void CalculateSize();
|
||||
|
||||
UINT m_InstanceCount;
|
||||
void* m_Skin;
|
||||
|
||||
RawString m_Path;
|
||||
bool m_IncludeSubFolders;
|
||||
bool m_IncludeHiddenFiles;
|
||||
bool m_IncludeSystemFiles;
|
||||
UINT64 m_Size;
|
||||
UINT m_FileCount;
|
||||
UINT m_FolderCount;
|
||||
pcre* m_RegExpFilter;
|
||||
DWORD m_LastUpdateTime;
|
||||
};
|
||||
|
@ -1,158 +1,158 @@
|
||||
/*
|
||||
Copyright (C) 2010 Elestel
|
||||
|
||||
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 <windows.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include "FolderInfo.h"
|
||||
#include "../API/RainmeterAPI.h"
|
||||
|
||||
enum MeasureType
|
||||
{
|
||||
MEASURE_FILECOUNT,
|
||||
MEASURE_FOLDERCOUNT,
|
||||
MEASURE_FOLDERSIZE
|
||||
};
|
||||
|
||||
struct MeasureData
|
||||
{
|
||||
LPCWSTR section;
|
||||
CFolderInfo* folder;
|
||||
MeasureType type;
|
||||
bool parent;
|
||||
|
||||
MeasureData(LPCWSTR section) :
|
||||
section(section),
|
||||
folder(),
|
||||
type(MEASURE_FILECOUNT),
|
||||
parent(false)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<MeasureData*> g_Measures;
|
||||
|
||||
PLUGIN_EXPORT void Initialize(void** data, void* rm)
|
||||
{
|
||||
MeasureData* measure = new MeasureData(RmGetMeasureName(rm));
|
||||
*data = measure;
|
||||
g_Measures.push_back(measure);
|
||||
|
||||
void* skin = RmGetSkin(rm);
|
||||
|
||||
LPCWSTR str = RmReadString(rm, L"Folder", L"", FALSE);
|
||||
if (*str == L'[')
|
||||
{
|
||||
const size_t len = wcslen(str);
|
||||
for (auto iter = g_Measures.cbegin(); iter != g_Measures.cend(); ++iter)
|
||||
{
|
||||
if ((*iter)->folder &&
|
||||
(*iter)->folder->GetSkin() == skin &&
|
||||
wcsncmp(&str[1], (*iter)->section, len - 2) == 0)
|
||||
{
|
||||
measure->folder = (*iter)->folder;
|
||||
measure->folder->AddInstance();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
measure->folder = new CFolderInfo(skin);
|
||||
measure->parent = true;
|
||||
}
|
||||
|
||||
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
|
||||
{
|
||||
MeasureData* measure = (MeasureData*)data;
|
||||
CFolderInfo* folder = measure->folder;
|
||||
|
||||
if (!folder)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LPCWSTR str = RmReadString(rm, L"InfoType", L"");
|
||||
if (_wcsicmp(str, L"FolderSize") == 0 || _wcsicmp(str, L"FolderSizeStr") == 0)
|
||||
{
|
||||
measure->type = MEASURE_FOLDERSIZE;
|
||||
}
|
||||
else if (_wcsicmp(str, L"FolderCount") == 0 || _wcsicmp(str, L"FolderCountStr") == 0)
|
||||
{
|
||||
measure->type = MEASURE_FOLDERCOUNT;
|
||||
}
|
||||
else if (_wcsicmp(str, L"FileCount") == 0 || _wcsicmp(str, L"FileCountStr") == 0)
|
||||
{
|
||||
measure->type = MEASURE_FILECOUNT;
|
||||
}
|
||||
|
||||
if (measure->parent)
|
||||
{
|
||||
str = RmReadPath(rm, L"Folder", L"");
|
||||
folder->SetPath(str);
|
||||
|
||||
str = RmReadString(rm, L"RegExpFilter", L"");
|
||||
folder->SetRegExpFilter(str);
|
||||
|
||||
folder->SetSubFolders(RmReadInt(rm, L"IncludeSubFolders", 0) == 1);
|
||||
folder->SetHiddenFiles(RmReadInt(rm, L"IncludeHiddenFiles", 0) == 1);
|
||||
folder->SetSystemFiles(RmReadInt(rm, L"IncludeSystemFiles", 0) == 1);
|
||||
}
|
||||
}
|
||||
|
||||
PLUGIN_EXPORT double Update(void* data)
|
||||
{
|
||||
MeasureData* measure = (MeasureData*)data;
|
||||
if (!measure->folder)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (measure->parent)
|
||||
{
|
||||
measure->folder->Update();
|
||||
}
|
||||
|
||||
switch (measure->type)
|
||||
{
|
||||
case MEASURE_FOLDERSIZE:
|
||||
return (double)measure->folder->GetSize();
|
||||
|
||||
case MEASURE_FILECOUNT:
|
||||
return measure->folder->GetFileCount();
|
||||
|
||||
case MEASURE_FOLDERCOUNT:
|
||||
return measure->folder->GetFolderCount();
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
PLUGIN_EXPORT void Finalize(void* data)
|
||||
{
|
||||
MeasureData* measure = (MeasureData*)data;
|
||||
|
||||
if (measure->folder)
|
||||
{
|
||||
measure->folder->RemoveInstance();
|
||||
}
|
||||
|
||||
delete measure;
|
||||
|
||||
std::vector<MeasureData*>::iterator iter = std::find(g_Measures.begin(), g_Measures.end(), measure);
|
||||
g_Measures.erase(iter);
|
||||
}
|
||||
/*
|
||||
Copyright (C) 2010 Elestel
|
||||
|
||||
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 <windows.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include "FolderInfo.h"
|
||||
#include "../API/RainmeterAPI.h"
|
||||
|
||||
enum MeasureType
|
||||
{
|
||||
MEASURE_FILECOUNT,
|
||||
MEASURE_FOLDERCOUNT,
|
||||
MEASURE_FOLDERSIZE
|
||||
};
|
||||
|
||||
struct MeasureData
|
||||
{
|
||||
LPCWSTR section;
|
||||
CFolderInfo* folder;
|
||||
MeasureType type;
|
||||
bool parent;
|
||||
|
||||
MeasureData(LPCWSTR section) :
|
||||
section(section),
|
||||
folder(),
|
||||
type(MEASURE_FILECOUNT),
|
||||
parent(false)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<MeasureData*> g_Measures;
|
||||
|
||||
PLUGIN_EXPORT void Initialize(void** data, void* rm)
|
||||
{
|
||||
MeasureData* measure = new MeasureData(RmGetMeasureName(rm));
|
||||
*data = measure;
|
||||
g_Measures.push_back(measure);
|
||||
|
||||
void* skin = RmGetSkin(rm);
|
||||
|
||||
LPCWSTR str = RmReadString(rm, L"Folder", L"", FALSE);
|
||||
if (*str == L'[')
|
||||
{
|
||||
const size_t len = wcslen(str);
|
||||
for (auto iter = g_Measures.cbegin(); iter != g_Measures.cend(); ++iter)
|
||||
{
|
||||
if ((*iter)->folder &&
|
||||
(*iter)->folder->GetSkin() == skin &&
|
||||
wcsncmp(&str[1], (*iter)->section, len - 2) == 0)
|
||||
{
|
||||
measure->folder = (*iter)->folder;
|
||||
measure->folder->AddInstance();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
measure->folder = new CFolderInfo(skin);
|
||||
measure->parent = true;
|
||||
}
|
||||
|
||||
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
|
||||
{
|
||||
MeasureData* measure = (MeasureData*)data;
|
||||
CFolderInfo* folder = measure->folder;
|
||||
|
||||
if (!folder)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LPCWSTR str = RmReadString(rm, L"InfoType", L"");
|
||||
if (_wcsicmp(str, L"FolderSize") == 0 || _wcsicmp(str, L"FolderSizeStr") == 0)
|
||||
{
|
||||
measure->type = MEASURE_FOLDERSIZE;
|
||||
}
|
||||
else if (_wcsicmp(str, L"FolderCount") == 0 || _wcsicmp(str, L"FolderCountStr") == 0)
|
||||
{
|
||||
measure->type = MEASURE_FOLDERCOUNT;
|
||||
}
|
||||
else if (_wcsicmp(str, L"FileCount") == 0 || _wcsicmp(str, L"FileCountStr") == 0)
|
||||
{
|
||||
measure->type = MEASURE_FILECOUNT;
|
||||
}
|
||||
|
||||
if (measure->parent)
|
||||
{
|
||||
str = RmReadPath(rm, L"Folder", L"");
|
||||
folder->SetPath(str);
|
||||
|
||||
str = RmReadString(rm, L"RegExpFilter", L"");
|
||||
folder->SetRegExpFilter(str);
|
||||
|
||||
folder->SetSubFolders(RmReadInt(rm, L"IncludeSubFolders", 0) == 1);
|
||||
folder->SetHiddenFiles(RmReadInt(rm, L"IncludeHiddenFiles", 0) == 1);
|
||||
folder->SetSystemFiles(RmReadInt(rm, L"IncludeSystemFiles", 0) == 1);
|
||||
}
|
||||
}
|
||||
|
||||
PLUGIN_EXPORT double Update(void* data)
|
||||
{
|
||||
MeasureData* measure = (MeasureData*)data;
|
||||
if (!measure->folder)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
if (measure->parent)
|
||||
{
|
||||
measure->folder->Update();
|
||||
}
|
||||
|
||||
switch (measure->type)
|
||||
{
|
||||
case MEASURE_FOLDERSIZE:
|
||||
return (double)measure->folder->GetSize();
|
||||
|
||||
case MEASURE_FILECOUNT:
|
||||
return measure->folder->GetFileCount();
|
||||
|
||||
case MEASURE_FOLDERCOUNT:
|
||||
return measure->folder->GetFolderCount();
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
PLUGIN_EXPORT void Finalize(void* data)
|
||||
{
|
||||
MeasureData* measure = (MeasureData*)data;
|
||||
|
||||
if (measure->folder)
|
||||
{
|
||||
measure->folder->RemoveInstance();
|
||||
}
|
||||
|
||||
delete measure;
|
||||
|
||||
std::vector<MeasureData*>::iterator iter = std::find(g_Measures.begin(), g_Measures.end(), measure);
|
||||
g_Measures.erase(iter);
|
||||
}
|
||||
|
@ -1,40 +1,40 @@
|
||||
#include <VerRsrc.h>
|
||||
#include "../../Version.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION PRODUCTVER
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE VFT_UNKNOWN
|
||||
{
|
||||
BLOCK "StringFileInfo"
|
||||
{
|
||||
BLOCK "040904E4"
|
||||
{
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
VALUE "LegalCopyright", "<22> 2010 - Elestel"
|
||||
VALUE "ProductName", "Rainmeter"
|
||||
#ifdef _WIN64
|
||||
VALUE "ProductVersion", STRPRODUCTVER " (64-bit)"
|
||||
#else
|
||||
VALUE "ProductVersion", STRPRODUCTVER " (32-bit)"
|
||||
#endif //_WIN64
|
||||
}
|
||||
}
|
||||
BLOCK "VarFileInfo"
|
||||
{
|
||||
VALUE "Translation", 0x409, 1252
|
||||
}
|
||||
}
|
||||
#include <VerRsrc.h>
|
||||
#include "../../Version.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION PRODUCTVER
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE VFT_UNKNOWN
|
||||
{
|
||||
BLOCK "StringFileInfo"
|
||||
{
|
||||
BLOCK "040904E4"
|
||||
{
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
VALUE "LegalCopyright", "<22> 2010 - Elestel"
|
||||
VALUE "ProductName", "Rainmeter"
|
||||
#ifdef _WIN64
|
||||
VALUE "ProductVersion", STRPRODUCTVER " (64-bit)"
|
||||
#else
|
||||
VALUE "ProductVersion", STRPRODUCTVER " (32-bit)"
|
||||
#endif //_WIN64
|
||||
}
|
||||
}
|
||||
BLOCK "VarFileInfo"
|
||||
{
|
||||
VALUE "Translation", 0x409, 1252
|
||||
}
|
||||
}
|
||||
|
@ -1,44 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.Default.props" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{A221819D-4263-42AA-B22A-C022924842A7}</ProjectGuid>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<TargetName>FolderInfo</TargetName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.props" />
|
||||
<Import Project="$(SolutionDir)Build\VS\RainmeterPlugin.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>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_USRDLL;HAVE_CONFIG_H;SUPPORT_UTF8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\config.h" />
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\pcre.h" />
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\pcre_internal.h" />
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\ucp.h" />
|
||||
<ClInclude Include="FolderInfo.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\Library\pcre-8.10\pcre_globals.c" />
|
||||
<ClCompile Include="FolderInfo.cpp" />
|
||||
<ClCompile Include="FolderInfoPlugin.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="PluginFolderInfo.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.Default.props" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{A221819D-4263-42AA-B22A-C022924842A7}</ProjectGuid>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<TargetName>FolderInfo</TargetName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.props" />
|
||||
<Import Project="$(SolutionDir)Build\VS\RainmeterPlugin.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>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>_USRDLL;HAVE_CONFIG_H;SUPPORT_UTF8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\config.h" />
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\pcre.h" />
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\pcre_internal.h" />
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\ucp.h" />
|
||||
<ClInclude Include="FolderInfo.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\Library\pcre-8.10\pcre_globals.c" />
|
||||
<ClCompile Include="FolderInfo.cpp" />
|
||||
<ClCompile Include="FolderInfoPlugin.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="PluginFolderInfo.rc" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,33 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="FolderInfo.h" />
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\pcre.h">
|
||||
<Filter>pcre</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\pcre_internal.h">
|
||||
<Filter>pcre</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\ucp.h">
|
||||
<Filter>pcre</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\config.h">
|
||||
<Filter>pcre</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="FolderInfo.cpp" />
|
||||
<ClCompile Include="FolderInfoPlugin.cpp" />
|
||||
<ClCompile Include="..\..\Library\pcre-8.10\pcre_globals.c">
|
||||
<Filter>pcre</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="PluginFolderInfo.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="pcre">
|
||||
<UniqueIdentifier>{aaeb51d4-65cd-4eb6-954f-724800c27387}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="FolderInfo.h" />
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\pcre.h">
|
||||
<Filter>pcre</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\pcre_internal.h">
|
||||
<Filter>pcre</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\ucp.h">
|
||||
<Filter>pcre</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\Library\pcre-8.10\config.h">
|
||||
<Filter>pcre</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="FolderInfo.cpp" />
|
||||
<ClCompile Include="FolderInfoPlugin.cpp" />
|
||||
<ClCompile Include="..\..\Library\pcre-8.10\pcre_globals.c">
|
||||
<Filter>pcre</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="PluginFolderInfo.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="pcre">
|
||||
<UniqueIdentifier>{aaeb51d4-65cd-4eb6-954f-724800c27387}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
Reference in New Issue
Block a user