mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
FolderInfo.dll now returns size in bytes. If using InfoType=FolderSizeStr (which until now autoscaled the value internally), AutoScale=1 should be added to the meter(s). While this does change behaviour, it allows for the use of Scale, NumOfDecimals, etc. that weren't possible prior to this change (without an extra Calc measure).
This commit is contained in:
parent
6bd209ffa3
commit
cde1e517ac
@ -33,7 +33,6 @@ extern "C"
|
||||
{
|
||||
__declspec( dllexport ) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id);
|
||||
__declspec( dllexport ) void Finalize(HMODULE instance, UINT id);
|
||||
__declspec( dllexport ) LPCTSTR GetString(UINT id, UINT flags);
|
||||
__declspec( dllexport ) UINT Update(UINT id);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
@ -41,12 +40,6 @@ extern "C"
|
||||
|
||||
enum InfoType
|
||||
{
|
||||
// folder info (string)
|
||||
INFOTYPE_FOLDERSIZESTR,
|
||||
INFOTYPE_FILECOUNTSTR,
|
||||
INFOTYPE_FOLDERCOUNTSTR,
|
||||
|
||||
// folder info (int)
|
||||
INFOTYPE_FOLDERSIZE,
|
||||
INFOTYPE_FILECOUNT,
|
||||
INFOTYPE_FOLDERCOUNT,
|
||||
@ -54,19 +47,6 @@ enum InfoType
|
||||
INFOTYPE_COUNT
|
||||
};
|
||||
|
||||
const static wchar_t* InfoTypeName[INFOTYPE_COUNT] =
|
||||
{
|
||||
// folder info (string)
|
||||
L"FolderSizeStr", // FIELD_FOLDERSIZESTR
|
||||
L"FileCountStr", // FIELD_FILECOUNTSTR
|
||||
L"FolderCountStr", // FIELD_FOLDERCOUNTSTR
|
||||
|
||||
// folder info (int)
|
||||
L"FolderSize", // FIELD_FOLDERSIZE
|
||||
L"FileCount", // FIELD_FILECOUNT
|
||||
L"FolderCount", // FIELD_FOLDERCOUNT
|
||||
};
|
||||
|
||||
struct MeasureInfo
|
||||
{
|
||||
InfoType Type;
|
||||
@ -99,7 +79,7 @@ static MeasureInfo* GetMeasureInfo(UINT aId)
|
||||
static FolderInfo* GetFolderInfo(const wchar_t* aPath, const wchar_t* aIniPath)
|
||||
{
|
||||
int pathLen = wcslen(aPath);
|
||||
if(pathLen > 2 && L'[' == aPath[0] && L']' == aPath[pathLen - 1]) {
|
||||
if (pathLen > 2 && L'[' == aPath[0] && L']' == aPath[pathLen - 1]) {
|
||||
MeasureIdMap::iterator it;
|
||||
for (it = sMeasures.begin(); it != sMeasures.end(); it++) {
|
||||
if (wcsncmp(&aPath[1], it->second->Section.c_str(), pathLen - 2) == 0) {
|
||||
@ -139,10 +119,14 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
measureInfo->Folder = GetFolderInfo(strFolder, iniFile);
|
||||
|
||||
const wchar_t* strInfoType = ReadConfigString(section, L"InfoType", L"");
|
||||
for (int i = 0; i < INFOTYPE_COUNT; i++) {
|
||||
if (_wcsicmp(strInfoType, InfoTypeName[i]) == 0) {
|
||||
measureInfo->Type = (InfoType)i;
|
||||
}
|
||||
if (_wcsicmp(strInfoType, L"FolderSize") == 0 || _wcsicmp(strInfoType, L"FolderSizeStr") == 0) {
|
||||
measureInfo->Type = INFOTYPE_FOLDERSIZE;
|
||||
}
|
||||
else if (_wcsicmp(strInfoType, L"FolderCount") == 0 || _wcsicmp(strInfoType, L"FolderCountStr") == 0) {
|
||||
measureInfo->Type = INFOTYPE_FOLDERCOUNT;
|
||||
}
|
||||
else if (_wcsicmp(strInfoType, L"FileCount") == 0 || _wcsicmp(strInfoType, L"FileCountStr") == 0) {
|
||||
measureInfo->Type = INFOTYPE_FILECOUNT;
|
||||
}
|
||||
|
||||
if (measureInfo->Folder) {
|
||||
@ -174,59 +158,6 @@ UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void FormatSize(wchar_t* buffer, size_t bufferSize, UINT64 size)
|
||||
{
|
||||
if ((size >> 40) > 0) {
|
||||
wsprintf(buffer, L"%d.%02d T", (int)(size >> 40), (int)(( size << 24 >> 54 ) / 10.24));
|
||||
}
|
||||
else if ((size >> 30) > 0) {
|
||||
wsprintf(buffer, L"%d.%02d G", (int)(size >> 30), (int)(( size << 34 >> 54 ) / 10.24));
|
||||
}
|
||||
else if ((size >> 20) > 0) {
|
||||
wsprintf(buffer, L"%d.%02d M", (int)(size >> 20), (int)(( size << 44 >> 54 ) / 10.24));
|
||||
}
|
||||
else if ((size >> 10) > 0) {
|
||||
wsprintf(buffer, L"%d.%02d k", (int)(size >> 10), (int)(( size << 54 >> 54 ) / 10.24));
|
||||
}
|
||||
else {
|
||||
wsprintf(buffer, L"%ld ", size);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static wchar_t buffer[MAX_PATH];
|
||||
buffer[0] = 0;
|
||||
|
||||
MeasureInfo* measureInfo = sMeasures[id];
|
||||
if (!measureInfo->Folder) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
int now = GetTickCount();
|
||||
if (now - measureInfo->Folder->GetLastUpdateTime() > UPDATE_TIME_MIN_MS) {
|
||||
measureInfo->Folder->Update();
|
||||
}
|
||||
|
||||
switch (measureInfo->Type)
|
||||
{
|
||||
case INFOTYPE_FOLDERSIZESTR:
|
||||
FormatSize(buffer, MAX_PATH, measureInfo->Folder->GetSize());
|
||||
break;
|
||||
case INFOTYPE_FILECOUNTSTR:
|
||||
wsprintf(buffer, L"%d", measureInfo->Folder->GetFileCount());
|
||||
break;
|
||||
case INFOTYPE_FOLDERCOUNTSTR:
|
||||
wsprintf(buffer, L"%d", measureInfo->Folder->GetFolderCount());
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
@ -292,7 +223,7 @@ void Finalize(HMODULE instance, UINT id)
|
||||
*/
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 0002;
|
||||
return 0003;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -12,7 +12,7 @@
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 0,2,0,0
|
||||
FILEVERSION 0,3,0,0
|
||||
PRODUCTVERSION PRODUCTVER
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
@ -29,7 +29,7 @@ BEGIN
|
||||
BLOCK "040904E4"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "FolderInfo Plugin for Rainmeter"
|
||||
VALUE "FileVersion", "0.2.0.0"
|
||||
VALUE "FileVersion", "0.3.0.0"
|
||||
VALUE "InternalName", "FolderInfo"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2010 - Elestel"
|
||||
VALUE "OriginalFilename", "FolderInfo.dll"
|
||||
|
Loading…
Reference in New Issue
Block a user