Skip to content

Commit f7426fd

Browse files
committed
modify:Wrapped function to get folder size
1 parent ffcd6c3 commit f7426fd

File tree

8 files changed

+78
-32
lines changed

8 files changed

+78
-32
lines changed

XEngine_Source/StorageModule_APIHelp/APIHelp_Api/APIHelp_Api.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,4 +406,52 @@ bool CAPIHelp_Api::APIHelp_Api_Boundary(XCHAR*** ppptszList, int nListCount, XCH
406406
}
407407
}
408408
return bRet;
409+
}
410+
/********************************************************************
411+
函数名称:APIHelp_Api_GetDIRSize
412+
函数功能:获得目录大小
413+
参数.一:lpszDIRStr
414+
In/Out:In
415+
类型:常量字符指针
416+
可空:N
417+
意思:输入要操作s的目录
418+
参数.二:pInt_DIRSize
419+
In/Out:Out
420+
类型:整数型指针
421+
可空:N
422+
意思:输出得到的目录大小
423+
返回值
424+
类型:逻辑型
425+
意思:是否成功
426+
备注:
427+
*********************************************************************/
428+
bool CAPIHelp_Api::APIHelp_Api_GetDIRSize(LPCXSTR lpszDIRStr, __int64u* pInt_DIRSize)
429+
{
430+
int nListCount = 0;
431+
int nPathType = 0;
432+
__int64u nDirCount = 0; //当前目录大小
433+
XCHAR** ppListFile;
434+
XCHAR tszFilePath[MAX_PATH] = {};
435+
436+
_tcsxcpy(tszFilePath, lpszDIRStr);
437+
BaseLib_OperatorString_GetPath(tszFilePath, &nPathType);
438+
//判断是绝对路径还是相对路径
439+
if (1 == nPathType)
440+
{
441+
_tcsxcat(tszFilePath, _X("\\*"));
442+
}
443+
else if (2 == nPathType)
444+
{
445+
_tcsxcat(tszFilePath, _X("/*"));
446+
}
447+
SystemApi_File_EnumFile(tszFilePath, &ppListFile, &nListCount, true, 1);
448+
for (int i = 0; i < nListCount; i++)
449+
{
450+
struct _xtstat st_FStat;
451+
_xtstat(ppListFile[i], &st_FStat);
452+
nDirCount += st_FStat.st_size;
453+
}
454+
BaseLib_OperatorMemory_Free((XPPPMEM)&ppListFile, nListCount);
455+
*pInt_DIRSize = nDirCount;
456+
return true;
409457
}

XEngine_Source/StorageModule_APIHelp/APIHelp_Api/APIHelp_Api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class CAPIHelp_Api
2424
bool APIHelp_Api_GetIPInfo(LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_IPADDRINFO* pSt_IPAddrInfo);
2525
bool APIHelp_Api_UrlParse(XCHAR*** ppptszList, int nListCount, XCHAR* ptszFileName, XCHAR* ptszKeyName);
2626
bool APIHelp_Api_Boundary(XCHAR*** ppptszList, int nListCount, XCHAR* ptszBoundStr);
27+
bool APIHelp_Api_GetDIRSize(LPCXSTR lpszDIRStr, __int64u* pInt_DIRSize);
2728
protected:
2829
private:
2930
};

XEngine_Source/StorageModule_APIHelp/APIHelp_Define.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,23 @@ extern "C" bool APIHelp_Api_UrlParse(XCHAR*** ppptszList, int nListCount, XCHAR*
308308
意思:是否成功
309309
备注:
310310
*********************************************************************/
311-
extern "C" bool APIHelp_Api_Boundary(XCHAR*** ppptszList, int nListCount, XCHAR* ptszBoundStr);
311+
extern "C" bool APIHelp_Api_Boundary(XCHAR*** ppptszList, int nListCount, XCHAR* ptszBoundStr);
312+
/********************************************************************
313+
函数名称:APIHelp_Api_GetDIRSize
314+
函数功能:获得目录大小
315+
参数.一:lpszDIRStr
316+
In/Out:In
317+
类型:常量字符指针
318+
可空:N
319+
意思:输入要操作s的目录
320+
参数.二:pInt_DIRSize
321+
In/Out:Out
322+
类型:整数型指针
323+
可空:N
324+
意思:输出得到的目录大小
325+
返回值
326+
类型:逻辑型
327+
意思:是否成功
328+
备注:
329+
*********************************************************************/
330+
extern "C" bool APIHelp_Api_GetDIRSize(LPCXSTR lpszDIRStr, __int64u* pInt_DIRSize);

XEngine_Source/StorageModule_APIHelp/APIHelp_Distributed/APIHelp_Distributed.cpp

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -318,36 +318,8 @@ bool CAPIHelp_Distributed::APIHelp_Distributed_UPStorage(list<XENGINE_STORAGEBUC
318318
//处理优先级
319319
if (stl_ListIterator->nLevel == nLastLevel)
320320
{
321-
int nListCount = 0;
322321
__int64u nDirCount = 0; //当前目录大小
323-
XCHAR** ppListFile;
324-
//处理路径是否有通配符
325-
XCHAR tszFilePath[MAX_PATH];
326-
memset(tszFilePath, '\0', MAX_PATH);
327-
328-
_tcsxcpy(tszFilePath, pSt_StorageBucket->tszFilePath);
329-
if (tszFilePath[_tcsxlen(tszFilePath) - 1] != '*')
330-
{
331-
int nPathType = 0;
332-
BaseLib_OperatorString_GetPath(tszFilePath, &nPathType);
333-
//判断是绝对路径还是相对路径
334-
if (1 == nPathType)
335-
{
336-
_tcsxcat(tszFilePath, _X("\\*"));
337-
}
338-
else if (2 == nPathType)
339-
{
340-
_tcsxcat(tszFilePath, _X("/*"));
341-
}
342-
}
343-
SystemApi_File_EnumFile(tszFilePath, &ppListFile, &nListCount, true, 1);
344-
for (int j = 0; j < nListCount; j++)
345-
{
346-
struct _xtstat st_FStat;
347-
_xtstat(ppListFile[j], &st_FStat);
348-
nDirCount += st_FStat.st_size;
349-
}
350-
BaseLib_OperatorMemory_Free((XPPPMEM)&ppListFile, nListCount);
322+
APIHelp_Api_GetDIRSize(pSt_StorageBucket->tszFilePath, &nDirCount);
351323
//如果当前目录大小大于设定的大小.那么忽略
352324
if (nDirCount >= APIHelp_Distributed_GetSize(stl_ListIterator->tszBuckSize))
353325
{
@@ -427,7 +399,6 @@ bool CAPIHelp_Distributed::APIHelp_Distributed_UPStorage(list<XENGINE_STORAGEBUC
427399
return false;
428400
}
429401
}
430-
431402
return true;
432403
}
433404
/********************************************************************

XEngine_Source/StorageModule_APIHelp/APIHelp_Error.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define ERROR_STORAGE_MODULE_APIHELP_PARAMENT 0x0030001 //参数错误
1414
#define ERROR_STORAGE_MODULE_APIHELP_PARSE 0x0030002 //解析失败
1515
#define ERROR_STORAGE_MODULE_APIHELP_NOTFOUND 0x0030003 //没有找到
16+
#define ERROR_STORAGE_MODULE_APIHELP_DISABLE 0x0030004 //被禁用
1617
#define ERROR_STORAGE_MODULE_APIHELP_NOTAUTH 0x0030010 //没有验证信息
1718
#define ERROR_STORAGE_MODULE_APIHELP_NOTSUPPORT 0x0030011 //不支持
1819
#define ERROR_STORAGE_MODULE_APIHELP_NOTLENGTH 0x0030012 //没有长度信息

XEngine_Source/StorageModule_APIHelp/StorageModule_APIHelp.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ EXPORTS
1414
APIHelp_Api_VerHash
1515
APIHelp_Api_GetIPInfo
1616
APIHelp_Api_UrlParse
17-
APIHelp_Api_Boundary
17+
APIHelp_Api_Boundary
18+
APIHelp_Api_GetDIRSize

XEngine_Source/StorageModule_APIHelp/pch.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,8 @@ extern "C" bool APIHelp_Api_UrlParse(XCHAR * **ppptszList, int nListCount, XCHAR
7777
extern "C" bool APIHelp_Api_Boundary(XCHAR * **ppptszList, int nListCount, XCHAR * ptszBoundStr)
7878
{
7979
return m_APIHelp.APIHelp_Api_Boundary(ppptszList, nListCount, ptszBoundStr);
80+
}
81+
extern "C" bool APIHelp_Api_GetDIRSize(LPCXSTR lpszDIRStr, __int64u * pInt_DIRSize)
82+
{
83+
return m_APIHelp.APIHelp_Api_GetDIRSize(lpszDIRStr, pInt_DIRSize);
8084
}

XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ bool XEngine_Task_HttpUPLoader(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, in
201201
return false;
202202
}
203203
}
204+
204205
int nPathType = 0;
205206
_xstprintf(tszFileDir, _X("%s/%s"), st_StorageBucket.tszFilePath, tszFileName);
206207
BaseLib_OperatorString_GetPath(tszFileDir, &nPathType);

0 commit comments

Comments
 (0)