|
|
@@ -846,7 +846,7 @@ int ResourceWatcherFSM::RemoveExpireVideoFileAndRecord(LPCTSTR dirName, int& del
|
|
|
|
|
|
struct dirent* dp = NULL;
|
|
|
while ((dp = readdir(d)) != NULL) {
|
|
|
- if ((!strncmp(dp->d_name, ".", 1)) || (!strncmp(dp->d_name, "..", 2))) {
|
|
|
+ if ((!strcmp(dp->d_name, ".")) || (!strcmp(dp->d_name, ".."))) {
|
|
|
continue;
|
|
|
}
|
|
|
strcpy(tempFilePath, dirName);
|
|
|
@@ -1093,7 +1093,7 @@ int ResourceWatcherFSM::ClearSpecifieFile(DealFileType fileType, LPCTSTR dirName
|
|
|
}
|
|
|
struct dirent* dp = NULL;
|
|
|
while ((dp = readdir(d)) != NULL) {
|
|
|
- if ((!strncmp(dp->d_name, ".", 1)) || (!strncmp(dp->d_name, "..", 2))) {
|
|
|
+ if ((!strcmp(dp->d_name, ".")) || (!strcmp(dp->d_name, ".."))) {
|
|
|
continue;
|
|
|
}
|
|
|
strcpy(tempFilePath, dirName);
|
|
|
@@ -1587,7 +1587,7 @@ int ResourceWatcherFSM::ProcessFileDelete(LPCTSTR lpszPath, int& nDelSucCnt, int
|
|
|
}
|
|
|
struct dirent* dp = NULL;
|
|
|
while ((dp = readdir(d)) != NULL) {
|
|
|
- if ((!strncmp(dp->d_name, ".", 1)) || (!strncmp(dp->d_name, "..", 2))) {
|
|
|
+ if ((!strcmp(dp->d_name, ".")) || (!strcmp(dp->d_name, ".."))) {
|
|
|
continue;
|
|
|
}
|
|
|
strcpy(tempFilePath, lpszPath);
|
|
|
@@ -1835,7 +1835,7 @@ int ResourceWatcherFSM::CalculateAllVideoSize(LPCTSTR lpszPath, unsigned long lo
|
|
|
}
|
|
|
struct dirent* dp = NULL;
|
|
|
while ((dp = readdir(d)) != NULL) {
|
|
|
- if ((!strncmp(dp->d_name, ".", 1)) || (!strncmp(dp->d_name, "..", 2))) {
|
|
|
+ if ((!strcmp(dp->d_name, ".")) || (!strcmp(dp->d_name, ".."))) {
|
|
|
continue;
|
|
|
}
|
|
|
strcpy(tempFilePath, lpszPath);
|
|
|
@@ -1925,7 +1925,7 @@ void ResourceWatcherFSM::SetSysValAndBroadcast(DWORD dwVal, LPCTSTR lpszMessage)
|
|
|
dwOldVal = dwVal;
|
|
|
}
|
|
|
|
|
|
-BOOL ResourceWatcherFSM::InitialFileEntity(LPCTSTR lpszPath, DWORD& dwFileCnt, const DWORD dwFilterAttributes)
|
|
|
+BOOL ResourceWatcherFSM::InitialDirectoryEntity(LPCTSTR lpszPath, DWORD& dwFileCnt, const DWORD dwFilterAttributes)
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
|
|
|
@@ -1949,7 +1949,7 @@ BOOL ResourceWatcherFSM::InitialFileEntity(LPCTSTR lpszPath, DWORD& dwFileCnt, c
|
|
|
return FALSE;
|
|
|
}
|
|
|
#endif //_MSC_VER
|
|
|
-
|
|
|
+
|
|
|
m_FileEntry.SubFiles.Clear();
|
|
|
m_FileEntry.FileNamesBuffer.Clear();
|
|
|
m_FileEntry.Current.Clear();
|
|
|
@@ -1964,26 +1964,31 @@ BOOL ResourceWatcherFSM::InitialFileEntity(LPCTSTR lpszPath, DWORD& dwFileCnt, c
|
|
|
CloseHandle(hFile);
|
|
|
hFile = NULL;
|
|
|
m_FileEntry.Current.mAttributes = GetFileAttributesA(lpszPath);
|
|
|
-
|
|
|
#else
|
|
|
struct stat st;
|
|
|
if (stat(lpszPath, &st) < 0) {
|
|
|
Dbg("stat %s failed.", lpszPath);
|
|
|
return FALSE;
|
|
|
}
|
|
|
+ //GetFileTime
|
|
|
m_FileEntry.Current.mftCreate = st.st_ctime;
|
|
|
m_FileEntry.Current.mftAccess = st.st_atime;
|
|
|
m_FileEntry.Current.mftModified = st.st_mtime;
|
|
|
-
|
|
|
+ m_FileEntry.Current.mAttributes = 0;
|
|
|
+ //GetFileAttributesA
|
|
|
+ if (S_ISDIR(st.st_mode))
|
|
|
+ m_FileEntry.Current.mAttributes |= FILE_ATTRIBUTE_DIRECTORY;
|
|
|
+ if (m_FileEntry.Current.mAttributes == 0)
|
|
|
+ m_FileEntry.Current.mAttributes = FILE_ATTRIBUTE_ARCHIVE;
|
|
|
+ if (!(st.st_mode & S_IWUSR))
|
|
|
+ m_FileEntry.Current.mAttributes |= FILE_ATTRIBUTE_READONLY;
|
|
|
#endif //_MSC_VER
|
|
|
|
|
|
m_FileEntry.Current.mFileSize = 0;
|
|
|
-
|
|
|
DWORD dwDir = 0, dwFile = 0;
|
|
|
GetSubFileInfors(&m_FileEntry, dwDir, dwFile, dwFilterAttributes);
|
|
|
- Dbg("Flag:dwDir:%u,dwFile:%u", dwDir, dwFile);
|
|
|
+ Dbg("Flag: dwDir:%u, dwFile: %u", dwDir, dwFile);
|
|
|
DisplayFileEntities(&m_FileEntry);
|
|
|
-
|
|
|
dwFileCnt = dwDir + dwFile;
|
|
|
return TRUE;
|
|
|
}
|
|
|
@@ -1991,34 +1996,35 @@ BOOL ResourceWatcherFSM::InitialFileEntity(LPCTSTR lpszPath, DWORD& dwFileCnt, c
|
|
|
DWORD ResourceWatcherFSM::InitialVolumes()
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
-
|
|
|
UINT uCount = 0;
|
|
|
#if defined(RVC_OS_WIN)
|
|
|
+ /*获取磁盘信息,该坐标下的内容作为是否遍历的标识*/
|
|
|
if (!sBDiskValStatus[MAX_VOLUME_COUNT]) {
|
|
|
CHAR szDrivers[BUFSIZE] = { 0 };
|
|
|
CHAR szVolumeName[MAX_PATH] = { 0 };
|
|
|
CHAR szFileSysName[MAX_PATH] = { 0 };
|
|
|
BOOL bRet = GetLogicalDriveStringsA(BUFSIZE - 1, szDrivers);
|
|
|
if (bRet) {
|
|
|
- int nDriNum = 0;
|
|
|
Dbg("szDrivers: %s", szDrivers);
|
|
|
for (CHAR* pTemp = szDrivers; *pTemp != '\0'; pTemp += 4) {
|
|
|
if (*pTemp >= 'a' && *pTemp <= 'z') *pTemp -= 32;
|
|
|
- nDriNum = *pTemp - 'A';
|
|
|
- sBDiskValStatus[nDriNum] = FALSE;
|
|
|
+ const int nDriNum = *pTemp - 'A';
|
|
|
if (DRIVE_FIXED == GetDriveType(pTemp)) {
|
|
|
DWORD dwMaxCompLen, dwFileSystemFlags;
|
|
|
bRet = GetVolumeInformation(pTemp, szVolumeName, MAX_PATH, NULL,
|
|
|
&dwMaxCompLen, &dwFileSystemFlags, szFileSysName, MAX_PATH);
|
|
|
sBDiskValStatus[nDriNum] = TRUE;
|
|
|
uCount++;
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ sBDiskValStatus[nDriNum] = FALSE;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (uCount > 0) {
|
|
|
sBDiskValStatus[MAX_VOLUME_COUNT] = TRUE;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
m_FileEntry.SubFiles.Clear();
|
|
|
m_FileEntry.FileNamesBuffer.Clear();
|
|
|
m_FileEntry.Current.Clear();
|
|
|
@@ -2037,9 +2043,8 @@ DWORD ResourceWatcherFSM::InitialVolumes()
|
|
|
volume.mFileSize = uiTotalFreeBytes.QuadPart;
|
|
|
}
|
|
|
volume.mLevel = 0;
|
|
|
- DWORD dwNameLen = strlen(szVolume);
|
|
|
- Append(m_FileEntry.FileNamesBuffer, (PBYTE)szVolume, dwNameLen, volume.mNameOffset);
|
|
|
- volume.mNameLength = dwNameLen;
|
|
|
+ volume.mNameLength = strlen(szVolume);
|
|
|
+ Append(m_FileEntry.FileNamesBuffer, (PBYTE)szVolume, volume.mNameLength, volume.mNameOffset);
|
|
|
volume.mAttributes = 0;
|
|
|
m_FileEntry.SubFiles.Append(&volume, 0, 1);
|
|
|
uCount++;
|
|
|
@@ -2047,17 +2052,22 @@ DWORD ResourceWatcherFSM::InitialVolumes()
|
|
|
}
|
|
|
}
|
|
|
DisplayFileEntities(&m_FileEntry);
|
|
|
+#else
|
|
|
+
|
|
|
#endif //RVC_OS_WIN
|
|
|
return uCount;
|
|
|
}
|
|
|
|
|
|
DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
- const SpReqAnsContext<ResourceWatcherService_OperateFile_Req,
|
|
|
- ResourceWatcherService_OperateFile_Ans>::Pointer& ctx)
|
|
|
+ const SpReqAnsContext<ResourceWatcherService_OperateFile_Req, ResourceWatcherService_OperateFile_Ans>::Pointer& ctx)
|
|
|
{
|
|
|
- if(ctx == NULL) return 0;
|
|
|
+ if (ctx == NULL) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
ResourceWatcherService_OperateFile_Req& req = ctx->Req;
|
|
|
ResourceWatcherService_OperateFile_Ans& ans = ctx->Ans;
|
|
|
+
|
|
|
{
|
|
|
ans.header = "";
|
|
|
ans.attachment1 = 0;
|
|
|
@@ -2069,32 +2079,28 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
ans.fileAttribute = 0U;
|
|
|
ans.count = 0;
|
|
|
}
|
|
|
- Dbg("size of current: %d", req.current.GetLength());
|
|
|
- CSimpleStringA strCurrent;
|
|
|
- size_t stCurLength = 0;
|
|
|
- if(!req.current.IsNullOrEmpty())
|
|
|
- {
|
|
|
+ CSimpleStringA strCurrent(true);
|
|
|
+ size_t nCurLen = req.current.GetLength();
|
|
|
+ Dbg("size of current dir: %d", nCurLen);
|
|
|
+ if(!req.current.IsNullOrEmpty()) {
|
|
|
CSimpleStringA strTemp = req.current.Trim();
|
|
|
size_t len = req.current.GetLength();
|
|
|
- while(len > 0 && (strTemp[len-1] == '\\' || strTemp[len-1] == '/'))
|
|
|
- {
|
|
|
- strTemp[len-1] = ' ';
|
|
|
+ while(len > 0 && (strTemp[len-1] == '\\' || strTemp[len-1] == '/')) {
|
|
|
+ strTemp[len-1] = '\0';
|
|
|
len--;
|
|
|
}
|
|
|
- if(len > 0)
|
|
|
- {
|
|
|
+ if(len > 0) {
|
|
|
strCurrent = strTemp.Trim();
|
|
|
- stCurLength = strCurrent.GetLength();
|
|
|
- LOG_ASSERT(len == stCurLength);
|
|
|
+ nCurLen = strCurrent.GetLength();
|
|
|
+ LOG_ASSERT(len == nCurLen);
|
|
|
+ Dbg("size of strCurrent: %d", nCurLen);
|
|
|
}
|
|
|
}
|
|
|
- Dbg("size of strCurrent: %d", stCurLength);
|
|
|
BOOL bCurNull = strCurrent.IsNullOrEmpty();
|
|
|
if(!bCurNull)
|
|
|
{
|
|
|
int nRes = FilterFilePathAhead(strCurrent, req.mode);
|
|
|
- if(nRes != 0)
|
|
|
- {
|
|
|
+ if(nRes != 0) {
|
|
|
ans.result = OPT_FILE_RES_FAILED;
|
|
|
CSimpleStringA strTxt;
|
|
|
switch(nRes)
|
|
|
@@ -2141,19 +2147,27 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
{
|
|
|
ans.result = OPT_FILE_RES_FAILED;
|
|
|
ans.attachment1 = GetErrorMessage(ans.attachment2, "请求的文件不存在或类型不正确。");
|
|
|
- Dbg("Before InitialFileEntity failed: %s", ans.attachment2.GetData());
|
|
|
+ Dbg("Before Initial File Entity failed: %s", ans.attachment2.GetData());
|
|
|
break;
|
|
|
}
|
|
|
DWORD dwFilterAttributes = (DWORD)(ctx->Req.filter1);
|
|
|
- if(bCurNull)
|
|
|
- {
|
|
|
+ if(bCurNull) {
|
|
|
+#if defined(_MSC_VER)
|
|
|
dwRes = InitialVolumes();
|
|
|
+#else
|
|
|
+ if (!InitialDirectoryEntity("/", dwRes, dwFilterAttributes)) {
|
|
|
+ ans.result = OPT_FILE_RES_FAILED;
|
|
|
+ ans.attachment1 = GetErrorMessage(ans.attachment2, "获取根目录列表失败");
|
|
|
+ Dbg("Initial File Entity failed: %s", ans.attachment2.GetData());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+#endif //_MSC_VER
|
|
|
}
|
|
|
- else if(!InitialFileEntity(strCurrent, dwRes, dwFilterAttributes))
|
|
|
+ else if(!InitialDirectoryEntity(strCurrent, dwRes, dwFilterAttributes))
|
|
|
{
|
|
|
ans.result = OPT_FILE_RES_FAILED;
|
|
|
ans.attachment1 = GetErrorMessage(ans.attachment2, "获取文件列表失败");
|
|
|
- Dbg("InitialFileEntity failed: %s", ans.attachment2.GetData());
|
|
|
+ Dbg("Initial File Entity failed: %s", ans.attachment2.GetData());
|
|
|
break;
|
|
|
}
|
|
|
Dbg("%d VS %d", dwRes, m_FileEntry.SubFiles.GetCount());
|
|
|
@@ -2178,58 +2192,40 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
if(req.attachment1 > 0 && req.attachment2.GetLength() > 0)
|
|
|
lpParam = req.attachment2;
|
|
|
DWORD dwRes = ExecuteFile(strCurrent, lpParam);
|
|
|
- if(!dwRes)
|
|
|
- {
|
|
|
- ans.result = OPT_FILE_RES_SUCCESS;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ans.result = OPT_FILE_RES_FAILED;
|
|
|
- {
|
|
|
- ans.attachment1 = GetErrorMessage(ans.attachment2, "执行文件操作失败。");
|
|
|
- Dbg("ExecuteFile failed: %s", (LPCTSTR)ans.attachment2);
|
|
|
- }
|
|
|
+ ans.result = dwRes ? OPT_FILE_RES_FAILED : OPT_FILE_RES_SUCCESS;
|
|
|
+ if (!!dwRes) {
|
|
|
+ ans.attachment1 = GetErrorMessage(ans.attachment2, "执行文件操作失败。");
|
|
|
+ Dbg("ExecuteFile failed: %s", (LPCTSTR)ans.attachment2);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case OPT_FILE_CMD_DELETE: //2
|
|
|
case OPT_FILE_CMD_CLEAR: //3
|
|
|
{
|
|
|
- if(ctx->Req.mode == OPT_FILE_CMD_DELETE)
|
|
|
- {
|
|
|
+ bool bClear = !!(ctx->Req.mode == OPT_FILE_CMD_CLEAR);
|
|
|
+ if(!bClear) {
|
|
|
Dbg("Delete flag.");
|
|
|
}
|
|
|
- if(type == FT_Unknown)
|
|
|
- {
|
|
|
+ if(type == FT_Unknown) {
|
|
|
ans.result = OPT_FILE_RES_INVALID;
|
|
|
ans.attachment1 = strlen("所指定的文件不存在。");
|
|
|
ans.attachment2 = "所指定的文件不存在。";
|
|
|
break;
|
|
|
}
|
|
|
- bool bClear = !!(ctx->Req.mode == OPT_FILE_CMD_CLEAR);
|
|
|
-
|
|
|
if(type == FT_Volume)
|
|
|
{
|
|
|
- if(!bClear)
|
|
|
- {
|
|
|
+ if(!bClear) {
|
|
|
ans.result = OPT_FILE_RES_INVALID;
|
|
|
- ans.attachment1 = strlen("该操作对卷类型的文件无效。");
|
|
|
ans.attachment2 = "该操作对卷类型的文件无效。";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if(ClearDirRecursiveA(strCurrent))
|
|
|
- {
|
|
|
- ans.result = OPT_FILE_RES_SUCCESS;
|
|
|
- bNeedToRefleshEntity = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ans.attachment1 = strlen("清空卷操作执行失败。");
|
|
|
- ans.attachment2 = "清空卷操作执行失败。";
|
|
|
- ans.result = OPT_FILE_RES_FAILED;
|
|
|
- }
|
|
|
- }
|
|
|
+ ans.attachment1 = ans.attachment2.GetLength();
|
|
|
+ } else if (ClearDirRecursiveA(strCurrent)) {
|
|
|
+ ans.result = OPT_FILE_RES_SUCCESS;
|
|
|
+ bNeedToRefleshEntity = true;
|
|
|
+ } else {
|
|
|
+ ans.attachment2 = "清空卷操作执行失败。";
|
|
|
+ ans.attachment1 = ans.attachment2.GetLength();
|
|
|
+ ans.result = OPT_FILE_RES_FAILED;
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
if((type == FT_Directory && ((!bClear && !RemoveDirRecursiveA(strCurrent))
|
|
|
@@ -2246,22 +2242,17 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
//simple implement
|
|
|
FILE* stream;
|
|
|
SetLastError(0);
|
|
|
- if((stream = fopen(strCurrent, "w+")) == NULL)
|
|
|
- {
|
|
|
+ if((stream = fopen(strCurrent, "w+")) == NULL) {
|
|
|
ans.attachment1 = GetErrorMessage(ans.attachment2, "清空文件内容执行失败。");
|
|
|
ans.result = OPT_FILE_RES_FAILED;
|
|
|
break;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- if(fclose(stream))
|
|
|
- {
|
|
|
- Dbg("fclose(%s) failed", (LPCTSTR)strCurrent);
|
|
|
- ans.attachment1 = GetErrorMessage(ans.attachment2, "清空文件内容执行失败。");
|
|
|
- ans.result = OPT_FILE_RES_FAILED;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
+ if (fclose(stream)) {
|
|
|
+ Dbg("fclose(%s) failed", (LPCTSTR)strCurrent);
|
|
|
+ ans.attachment1 = GetErrorMessage(ans.attachment2, "清空文件内容执行失败。");
|
|
|
+ ans.result = OPT_FILE_RES_FAILED;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
ans.result = OPT_FILE_RES_SUCCESS;
|
|
|
bNeedToRefleshEntity = true;
|
|
|
@@ -2272,18 +2263,12 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
break;
|
|
|
case OPT_FILE_CMD_CREATE: //4
|
|
|
{
|
|
|
- if(type != FT_Unknown)
|
|
|
- {
|
|
|
- if((type == FT_Directory && (req.attribute & 0x10))
|
|
|
- || (type == FT_File && !(req.attribute & 0x10))
|
|
|
- || type == FT_Volume)
|
|
|
- {
|
|
|
- Dbg("Existed file occurs create(%d) ?", type);
|
|
|
- ans.result = OPT_FILE_RES_FAILED;
|
|
|
- ans.attachment1 = strlen("目录或文件已存在。");
|
|
|
- ans.attachment2 = "目录或文件已存在。";
|
|
|
- break;
|
|
|
- }
|
|
|
+ if ((type == FT_Directory && (req.attribute & 0x10)) || (type == FT_File && !(req.attribute & 0x10)) || type == FT_Volume) {
|
|
|
+ Dbg("Existed file occurs create(%d) ?", type);
|
|
|
+ ans.result = OPT_FILE_RES_FAILED;
|
|
|
+ ans.attachment1 = strlen("目录或文件已存在。");
|
|
|
+ ans.attachment2 = "目录或文件已存在。";
|
|
|
+ break;
|
|
|
}
|
|
|
BOOL bRet = FALSE;
|
|
|
int depth = GetPathDepth(strCurrent);
|
|
|
@@ -2291,25 +2276,21 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
{
|
|
|
Dbg("Invalid file path(%s)", (LPCTSTR)strCurrent);
|
|
|
ans.result = OPT_FILE_RES_FAILED;
|
|
|
- ans.attachment1 = strlen("非法文件路径或名称。");
|
|
|
ans.attachment2 = "非法文件路径或名称。";
|
|
|
+ ans.attachment1 = ans.attachment2.GetLength();
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if(req.attribute & 0x10)
|
|
|
- {
|
|
|
+ if(req.attribute & 0x10) {
|
|
|
Dbg("Start to create directory");
|
|
|
- bRet = CreateDirA(strCurrent, TRUE);
|
|
|
- if(!bRet)
|
|
|
+ if(!CreateDirA(strCurrent, TRUE))
|
|
|
{
|
|
|
ans.attachment1 = GetErrorMessage(ans.attachment2, "新建文件夹失败。");
|
|
|
Dbg("Create directory failed: %s", ans.attachment2.GetData());
|
|
|
ans.result = OPT_FILE_RES_FAILED;
|
|
|
break;
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
if(depth == 1/*根目录下创建文件*/ || CreateParentDirA(strCurrent, TRUE))
|
|
|
{
|
|
|
#if defined(_MSC_VER)
|
|
|
@@ -2366,14 +2347,14 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
if (type != FT_File) {
|
|
|
Dbg("file is not existed(%d) ?", type);
|
|
|
ans.result = OPT_FILE_RES_FAILED;
|
|
|
- ans.attachment1 = strlen("目标文件不存在或非文件类型。");
|
|
|
ans.attachment2 = "目标文件不存在或非文件类型。";
|
|
|
+ ans.attachment1 = ans.attachment2.GetLength();
|
|
|
break;
|
|
|
} else if (req.content.GetLength() <= 0) {
|
|
|
Dbg("invalid file content %d", req.content.GetLength());
|
|
|
ans.result = OPT_FILE_RES_FAILED;
|
|
|
- ans.attachment1 = strlen("写入的文件内容不存在。");
|
|
|
ans.attachment2 = "写入的文件内容不存在。";
|
|
|
+ ans.attachment1 = ans.attachment2.GetLength();
|
|
|
break;
|
|
|
}
|
|
|
DWORD dwBytesToWrite = (DWORD)req.content.GetLength();
|
|
|
@@ -2392,8 +2373,7 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
dwBytesToWrite, &dwByteWritten, NULL);
|
|
|
UnlockFile(hNewFile, dwPos, 0, dwBytesToWrite, 0);
|
|
|
if (!bRes || dwByteWritten != dwBytesToWrite) {
|
|
|
- ans.attachment1 = GetErrorMessage(ans.attachment2,
|
|
|
- !bRes ? "写入文件操作失败。" : "文件数据写入不完整。");
|
|
|
+ ans.attachment1 = GetErrorMessage(ans.attachment2, !bRes ? "写入文件操作失败。" : "文件数据写入不完整。");
|
|
|
Dbg("Append file failed: %s", ans.attachment2.GetData());
|
|
|
Dbg("Append file is incompletely(%u/%u)", dwByteWritten, dwBytesToWrite);
|
|
|
ans.result = OPT_FILE_RES_FAILED;
|
|
|
@@ -2414,20 +2394,11 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
case OPT_FILE_CMD_RENAME: //6
|
|
|
{
|
|
|
Dbg("Rename a file ? it would be critical...");
|
|
|
- if(type == FT_Unknown || type == FT_Volume)
|
|
|
- {
|
|
|
+ if(type == FT_Unknown || type == FT_Volume) {
|
|
|
Dbg("file is not existed(%d)?", type);
|
|
|
ans.result = OPT_FILE_RES_FAILED;
|
|
|
- if(type == FT_Unknown)
|
|
|
- {
|
|
|
- ans.attachment1 = strlen("目标文件不存在。");
|
|
|
- ans.attachment2 = "目标文件不存在。";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ans.attachment1 = strlen("文件类型(卷)不支持当前操作。");
|
|
|
- ans.attachment2 = "文件类型(卷)不支持当前操作。";
|
|
|
- }
|
|
|
+ ans.attachment2 = type == FT_Unknown ? "目标文件不存在。" : "文件类型(卷)不支持当前操作。";
|
|
|
+ ans.attachment1 = ans.attachment2.GetLength();
|
|
|
break;
|
|
|
}
|
|
|
req.content = req.content.Trim();
|
|
|
@@ -2435,24 +2406,25 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
{
|
|
|
Dbg("empty new file name ?");
|
|
|
ans.result = OPT_FILE_RES_FAILED;
|
|
|
- ans.attachment1 = strlen("传入新文件名参数为空。");
|
|
|
ans.attachment2 = "传入新文件名参数为空。";
|
|
|
+ ans.attachment1 = ans.attachment2.GetLength();
|
|
|
break;
|
|
|
}
|
|
|
if(strchr(req.content, '\\') || strchr(req.content, '/'))
|
|
|
{
|
|
|
Dbg("invalid new file name: %s", (LPCTSTR)req.content);
|
|
|
ans.result = OPT_FILE_RES_FAILED;
|
|
|
- ans.attachment1 = strlen("新文件名参数无效。");
|
|
|
ans.attachment2 = "新文件名参数无效。";
|
|
|
+ ans.attachment1 = ans.attachment2.GetLength();
|
|
|
break;
|
|
|
}
|
|
|
- const size_t st_len = stCurLength+req.content.GetLength();
|
|
|
+ const size_t st_len = nCurLen+req.content.GetLength();
|
|
|
char* path = new char[st_len];
|
|
|
ZeroMemory(path, st_len);
|
|
|
int res = 0;
|
|
|
if(path == NULL)
|
|
|
{
|
|
|
+ res = 1;
|
|
|
LogWarn(Severity_Middle, Error_Resource, 0, "alloc path memory failed");
|
|
|
}
|
|
|
else
|
|
|
@@ -2476,6 +2448,7 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
else
|
|
|
{
|
|
|
Dbg("GetDirSplitPath failed: %s vs %s", (LPCTSTR)strCurrent, path);
|
|
|
+ res = 1;
|
|
|
}
|
|
|
delete[] path;
|
|
|
path = NULL;
|
|
|
@@ -2484,8 +2457,8 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
{
|
|
|
Dbg("rename failed: %d", errno);
|
|
|
ans.result = OPT_FILE_RES_FAILED;
|
|
|
- ans.attachment1 = strlen("重命名操作失败。");
|
|
|
ans.attachment2 = "重命名操作失败。";
|
|
|
+ ans.attachment1 = ans.attachment2.GetLength();
|
|
|
break;
|
|
|
}
|
|
|
ans.result = OPT_FILE_RES_SUCCESS;
|
|
|
@@ -2515,11 +2488,11 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
CSimpleStringA strHeader = strCurrent;
|
|
|
if(updateLevel != 0)
|
|
|
{
|
|
|
- char* pPath = new char[stCurLength+1];
|
|
|
+ char* pPath = new char[nCurLen+1];
|
|
|
if(pPath == NULL) bReInit = false;
|
|
|
else
|
|
|
{
|
|
|
- UINT uRes = GetDirSplitPath(strHeader, updateLevel, pPath, stCurLength+1);
|
|
|
+ UINT uRes = GetDirSplitPath(strHeader, updateLevel, pPath, nCurLen+1);
|
|
|
if(uRes == 0) bReInit = false;
|
|
|
strHeader = pPath;
|
|
|
delete[] pPath;
|
|
|
@@ -2528,7 +2501,7 @@ DWORD ResourceWatcherFSM::ProcessFileOperation(
|
|
|
}
|
|
|
if(bReInit)
|
|
|
{
|
|
|
- bReInit = !!InitialFileEntity(strHeader, dwCnt);
|
|
|
+ bReInit = !!InitialDirectoryEntity(strHeader, dwCnt);
|
|
|
}
|
|
|
bNeedToRefleshHeader = true;
|
|
|
}
|
|
|
@@ -2596,6 +2569,7 @@ DWORD ResourceWatcherFSM::ExecuteFile(LPCTSTR lpszFilePath, LPCTSTR lpParam)
|
|
|
return dwRes;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
BOOL ResourceWatcherFSM::ConveyFileEntityToContext(const SpReqAnsContext<ResourceWatcherService_OperateFile_Req,
|
|
|
ResourceWatcherService_OperateFile_Ans>::Pointer& ctx
|
|
|
, BOOL bRefleshHeader /*= FALSE*/, DWORD dwFilterAttributes)
|
|
|
@@ -2620,14 +2594,13 @@ BOOL ResourceWatcherFSM::ConveyFileEntityToContext(const SpReqAnsContext<Resourc
|
|
|
if (!ctx->Ans.header.IsNullOrEmpty() && ctx->Ans.header.GetLength() > 0) {
|
|
|
if (InBlackListOrNot(ctx->Ans.header, OPT_FILE_CMD_DELETE)) {
|
|
|
dwInheritForbidAttrs |= BS_DENY_DELETE;
|
|
|
- Dbg("header-forbit:%s", ctx->Ans.header);
|
|
|
+ Dbg("header-forbit:%s", ctx->Ans.header.GetData());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
int count = m_FileEntry.SubFiles.GetCount();
|
|
|
int minusCount = 0;
|
|
|
-
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
if (m_FileEntry.SubFiles[i].mAttributes & dwFilterAttributes)
|
|
|
minusCount++;
|
|
|
@@ -2645,7 +2618,6 @@ BOOL ResourceWatcherFSM::ConveyFileEntityToContext(const SpReqAnsContext<Resourc
|
|
|
char szFormat[128] = { 0 };
|
|
|
count = MAX_SUBFILES_COUNT;
|
|
|
ctx->Ans.count = count;
|
|
|
-
|
|
|
ctx->Ans.fileAttributes.Init(count);
|
|
|
ctx->Ans.fileNames.Init(count);
|
|
|
ctx->Ans.ftCreates.Init(count);
|
|
|
@@ -2670,12 +2642,12 @@ BOOL ResourceWatcherFSM::ConveyFileEntityToContext(const SpReqAnsContext<Resourc
|
|
|
ctx->Ans.ftAccesses[i] = component->mftAccess;
|
|
|
ctx->Ans.fileSizes[i] = component->mFileSize;
|
|
|
//TODO: Need to judge whether need to calculate size of directory.
|
|
|
- GetSubFileName(m_FileEntry.FileNamesBuffer,
|
|
|
- dwBufSize, ctx->Ans.fileNames[i], &ilOffsetSize);
|
|
|
+ GetSubFileName(m_FileEntry.FileNamesBuffer, dwBufSize, ctx->Ans.fileNames[i], &ilOffsetSize);
|
|
|
+ Dbg("ADD: %s", ctx->Ans.fileNames[i].GetData());
|
|
|
ctx->Ans.forbidAttributes[i] = 0;
|
|
|
if (m_FileEntry.Current.mNameLength == 0 && ctx->Ans.fileAttributes[i] == 0) {
|
|
|
ctx->Ans.forbidAttributes[i] |= BS_DENY_DELETE;
|
|
|
- } else if (!ctx->Ans.fileNames[i].IsNullOrEmpty() && ctx->Ans.fileNames[i].GetLength() > 0) {
|
|
|
+ } else if (!ctx->Ans.fileNames[i].IsNullOrEmpty()) {
|
|
|
CSimpleStringA csFilePath;
|
|
|
GetFullFilePath(&m_FileEntry, i, csFilePath);
|
|
|
if (InBlackListOrNot(csFilePath, OPT_FILE_CMD_DELETE)) {
|
|
|
@@ -2709,12 +2681,12 @@ BOOL ResourceWatcherFSM::ConveyFileEntityToContext(const SpReqAnsContext<Resourc
|
|
|
ctx->Ans.ftAccesses[i] = m_FileEntry.SubFiles[i].mftAccess;
|
|
|
ctx->Ans.fileSizes[i] = m_FileEntry.SubFiles[i].mFileSize;
|
|
|
//TODO: Need to judge whether need to calculate size of directory.
|
|
|
- GetSubFileName(m_FileEntry.FileNamesBuffer,
|
|
|
- dwBufSize, ctx->Ans.fileNames[i], &ilOffsetSize);
|
|
|
+ GetSubFileName(m_FileEntry.FileNamesBuffer, dwBufSize, ctx->Ans.fileNames[i], &ilOffsetSize);
|
|
|
ctx->Ans.forbidAttributes[i] = 0;
|
|
|
+ Dbg("ADD: %s", ctx->Ans.fileNames[i].GetData());
|
|
|
if (m_FileEntry.Current.mNameLength == 0 && ctx->Ans.fileAttributes[i] == 0) {
|
|
|
ctx->Ans.forbidAttributes[i] |= BS_DENY_DELETE;
|
|
|
- } else if (!ctx->Ans.fileNames[i].IsNullOrEmpty() && ctx->Ans.fileNames[i].GetLength() > 0) {
|
|
|
+ } else if (!ctx->Ans.fileNames[i].IsNullOrEmpty()) {
|
|
|
CSimpleStringA csFilePath;
|
|
|
GetFullFilePath(&m_FileEntry, i, csFilePath);
|
|
|
if (InBlackListOrNot(csFilePath, OPT_FILE_CMD_DELETE)) {
|
|
|
@@ -2740,10 +2712,10 @@ BOOL ResourceWatcherFSM::ConveyFileEntityToContext(const SpReqAnsContext<Resourc
|
|
|
ctx->Ans.ftModified = m_FileEntry.Current.mftModified;
|
|
|
ctx->Ans.ftCreate = m_FileEntry.Current.mftCreate;
|
|
|
ctx->Ans.fileSize = m_FileEntry.Current.mFileSize;
|
|
|
- if (!ctx->Ans.header.IsNullOrEmpty() && ctx->Ans.header.GetLength() > 0) {
|
|
|
+ if (!ctx->Ans.header.IsNullOrEmpty()) {
|
|
|
if (InBlackListOrNot(ctx->Ans.header, OPT_FILE_CMD_DELETE)) {
|
|
|
dwInheritForbidAttrs |= BS_DENY_DELETE;
|
|
|
- Dbg("header-forbit:%s", ctx->Ans.header);
|
|
|
+ Dbg("header-forbit:%s", ctx->Ans.header.GetData());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2782,8 +2754,7 @@ BOOL ResourceWatcherFSM::ConveyFileEntityToContext(const SpReqAnsContext<Resourc
|
|
|
ilOffsetSize.u.HighPart = component->mNameLength;
|
|
|
if (component->mAttributes & dwFilterAttributes) {
|
|
|
CSimpleStringA strFileName;
|
|
|
- GetSubFileName(m_FileEntry.FileNamesBuffer,
|
|
|
- dwBufSize, strFileName, &ilOffsetSize);
|
|
|
+ GetSubFileName(m_FileEntry.FileNamesBuffer,dwBufSize, strFileName, &ilOffsetSize);
|
|
|
Dbg("%s reserved: 0x%X", strFileName.GetData(), component->mAttributes);
|
|
|
continue;
|
|
|
}
|
|
|
@@ -2793,12 +2764,12 @@ BOOL ResourceWatcherFSM::ConveyFileEntityToContext(const SpReqAnsContext<Resourc
|
|
|
ctx->Ans.ftAccesses[i] = component->mftAccess;
|
|
|
ctx->Ans.fileSizes[i] = component->mFileSize;
|
|
|
//TODO: Need to judge whether need to calculate size of directory.
|
|
|
- GetSubFileName(m_FileEntry.FileNamesBuffer,
|
|
|
- dwBufSize, ctx->Ans.fileNames[i], &ilOffsetSize);
|
|
|
+ GetSubFileName(m_FileEntry.FileNamesBuffer, dwBufSize, ctx->Ans.fileNames[i], &ilOffsetSize);
|
|
|
ctx->Ans.forbidAttributes[i] = 0;
|
|
|
+ Dbg("ADD: %s", ctx->Ans.fileNames[i].GetData());
|
|
|
if (m_FileEntry.Current.mNameLength == 0 && ctx->Ans.fileAttributes[i] == 0) {
|
|
|
ctx->Ans.forbidAttributes[i] |= BS_DENY_DELETE;
|
|
|
- } else if (!ctx->Ans.fileNames[i].IsNullOrEmpty() && ctx->Ans.fileNames[i].GetLength() > 0) {
|
|
|
+ } else if (!ctx->Ans.fileNames[i].IsNullOrEmpty()) {
|
|
|
CSimpleStringA csFilePath;
|
|
|
GetFullFilePath(&m_FileEntry, i, csFilePath);
|
|
|
if (InBlackListOrNot(csFilePath, OPT_FILE_CMD_DELETE)) {
|
|
|
@@ -2821,8 +2792,7 @@ BOOL ResourceWatcherFSM::ConveyFileEntityToContext(const SpReqAnsContext<Resourc
|
|
|
ilOffsetSize.u.HighPart = m_FileEntry.SubFiles[i].mNameLength;
|
|
|
if (m_FileEntry.SubFiles[i].mAttributes & dwFilterAttributes) {
|
|
|
CSimpleStringA strFileName;
|
|
|
- GetSubFileName(m_FileEntry.FileNamesBuffer,
|
|
|
- dwBufSize, strFileName, &ilOffsetSize);
|
|
|
+ GetSubFileName(m_FileEntry.FileNamesBuffer,dwBufSize, strFileName, &ilOffsetSize);
|
|
|
Dbg("%s reserved: 0x%X", strFileName.GetData(), m_FileEntry.SubFiles[i].mAttributes);
|
|
|
continue;
|
|
|
}
|
|
|
@@ -2832,12 +2802,12 @@ BOOL ResourceWatcherFSM::ConveyFileEntityToContext(const SpReqAnsContext<Resourc
|
|
|
ctx->Ans.ftAccesses[i] = m_FileEntry.SubFiles[i].mftAccess;
|
|
|
ctx->Ans.fileSizes[i] = m_FileEntry.SubFiles[i].mFileSize;
|
|
|
//TODO: Need to judge whether need to calculate size of directory.
|
|
|
- GetSubFileName(m_FileEntry.FileNamesBuffer,
|
|
|
- dwBufSize, ctx->Ans.fileNames[i], &ilOffsetSize);
|
|
|
+ GetSubFileName(m_FileEntry.FileNamesBuffer,dwBufSize, ctx->Ans.fileNames[i], &ilOffsetSize);
|
|
|
ctx->Ans.forbidAttributes[i] = 0;
|
|
|
+ Dbg("ADD: %s", ctx->Ans.fileNames[i].GetData());
|
|
|
if (m_FileEntry.Current.mNameLength == 0 && ctx->Ans.fileAttributes[i] == 0) {
|
|
|
ctx->Ans.forbidAttributes[i] |= BS_DENY_DELETE;
|
|
|
- } else if (!ctx->Ans.fileNames[i].IsNullOrEmpty() && ctx->Ans.fileNames[i].GetLength() > 0) {
|
|
|
+ } else if (!ctx->Ans.fileNames[i].IsNullOrEmpty()) {
|
|
|
CSimpleStringA csFilePath;
|
|
|
GetFullFilePath(&m_FileEntry, i, csFilePath);
|
|
|
if (InBlackListOrNot(csFilePath, OPT_FILE_CMD_DELETE)) {
|
|
|
@@ -2859,59 +2829,54 @@ BOOL ResourceWatcherFSM::ConveyFileEntityToContext(const SpReqAnsContext<Resourc
|
|
|
|
|
|
int ResourceWatcherFSM::FilterFilePathAhead(LPCTSTR lpszPath, const int option)
|
|
|
{
|
|
|
- if(lpszPath == NULL || strlen(lpszPath) <= 1)
|
|
|
- return -1;
|
|
|
- size_t len = strlen(lpszPath);
|
|
|
- if(!( (lpszPath[0] <= 'z' && lpszPath[0] >= 'a') || (lpszPath[0] <= 'Z' && lpszPath[0] >= 'A'))
|
|
|
- || lpszPath[1] != ':')
|
|
|
- {
|
|
|
- Dbg("illegal disk format path !");
|
|
|
- return -2;
|
|
|
- }
|
|
|
- //if(sBDiskValStatus[MAX_VOLUME_COUNT])
|
|
|
- {
|
|
|
- char disk = lpszPath[0];
|
|
|
- if(disk >= 'a' && disk <= 'z') disk -= 32;
|
|
|
- int diskNo = disk - 'A';
|
|
|
- if(!sBDiskValStatus[diskNo])
|
|
|
- {
|
|
|
- Dbg("Specified disk(%c) not existed", disk);
|
|
|
- return -3;
|
|
|
- }
|
|
|
- }
|
|
|
+#if defined(RVC_OS_WIN)
|
|
|
+ size_t len = strlen(lpszPath);
|
|
|
+ if (!((lpszPath[0] <= 'z' && lpszPath[0] >= 'a') || (lpszPath[0] <= 'Z' && lpszPath[0] >= 'A'))
|
|
|
+ || lpszPath[1] != ':') {
|
|
|
+ Dbg("illegal disk format path !");
|
|
|
+ return -2;
|
|
|
+ }
|
|
|
|
|
|
- char* path = new char[len+1];
|
|
|
- LOG_ASSERT(path != NULL);
|
|
|
- memset(path, 0, sizeof(char)*(len+1));
|
|
|
- memcpy(path, lpszPath, len);
|
|
|
- path[len] = '\0';
|
|
|
- int pos = len-1;
|
|
|
- for(; pos >= 0 && (path[pos] == '\\' || path[pos] == '/'); --pos)
|
|
|
- {
|
|
|
- ;//
|
|
|
- }
|
|
|
- path[pos+1] = '\0';
|
|
|
- len = strlen(path);
|
|
|
- if(len <= 1)
|
|
|
- {
|
|
|
- delete[] path;
|
|
|
- return -1;
|
|
|
- }
|
|
|
- else if(len == 2)
|
|
|
- {
|
|
|
- if(option == 2)
|
|
|
- {
|
|
|
- delete[] path;
|
|
|
- return 1;
|
|
|
- }
|
|
|
- }
|
|
|
- if(InBlackListOrNot(path, option))
|
|
|
- {
|
|
|
- delete[] path;
|
|
|
- return 2;
|
|
|
- }
|
|
|
- delete[] path;
|
|
|
+ const char disk = lpszPath[0];
|
|
|
+ if (disk >= 'a' && disk <= 'z') disk -= 32;
|
|
|
+ if (!sBDiskValStatus[int(disk - 'A')]) {
|
|
|
+ Dbg("Specified disk(%c) not existed", disk);
|
|
|
+ return -3;
|
|
|
+ }
|
|
|
+
|
|
|
+ char* path = new char[len + 1];
|
|
|
+ LOG_ASSERT(path != NULL);
|
|
|
+ memset(path, 0, sizeof(char) * (len + 1));
|
|
|
+ memcpy(path, lpszPath, len);
|
|
|
+ path[len] = '\0';
|
|
|
+ int pos = len - 1;
|
|
|
+ for (; pos >= 0 && (path[pos] == '\\' || path[pos] == '/'); --pos) {
|
|
|
+ ;//
|
|
|
+ }
|
|
|
+ path[pos + 1] = '\0';
|
|
|
+ len = strlen(path);
|
|
|
+ if (len <= 1) {
|
|
|
+ delete[] path;
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ else if (len == 2 && option == OPT_FILE_CMD_DELETE) {
|
|
|
+ /*disk volumn to delete*/
|
|
|
+ delete[] path;
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ if (InBlackListOrNot(path, option)) {
|
|
|
+ delete[] path;
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
+ delete[] path;
|
|
|
+ return 0;
|
|
|
+#else
|
|
|
+
|
|
|
+ Dbg("ignore all forbid mechansim");
|
|
|
return 0;
|
|
|
+
|
|
|
+#endif //RVC_OS_WIN
|
|
|
+
|
|
|
}
|
|
|
|
|
|
BOOL ResourceWatcherFSM::InBlackListOrNot(LPCTSTR lpszPath, const int option)
|
|
|
@@ -2951,33 +2916,32 @@ BOOL ResourceWatcherFSM::InBlackListOrNot(LPCTSTR lpszPath, const int option)
|
|
|
}
|
|
|
memset(temp_path, 0, sizeof(char)*(len+1));
|
|
|
strcpy_s(temp_path, len+1, lpszPath);
|
|
|
-#if defined(RVC_OS_WIN)
|
|
|
for (size_t i = 0; i < len; ++i) {
|
|
|
+#if defined(_MSC_VER)
|
|
|
if (temp_path[i] == '/')
|
|
|
temp_path[i] = '\\';
|
|
|
+#else
|
|
|
+ if (temp_path[i] == '\\')
|
|
|
+ temp_path[i] = '/';
|
|
|
+#endif //_MSC_VER
|
|
|
}
|
|
|
-#endif //RVC_OS_WIN
|
|
|
lpszPath = temp_path;
|
|
|
+
|
|
|
for(const_bs_iter cit = m_forbidDirList.cbegin(); cit != m_forbidDirList.cend() && !bForbidden; ++cit)
|
|
|
{
|
|
|
const bs_key& path = cit->first;
|
|
|
const bs_value& resist = cit->second;
|
|
|
const size_t n = strlen(path.c_str());
|
|
|
-
|
|
|
if(dwRequredAttr & resist)
|
|
|
{
|
|
|
- if(path[0] == '*')
|
|
|
- {
|
|
|
+ if(path[0] == '*') {
|
|
|
bForbidden = TRUE;
|
|
|
Dbg("Forbit0");
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
if(!_strnicmp(lpszPath, path.c_str(), min(len, n)))
|
|
|
{
|
|
|
- if(len > n
|
|
|
- && (lpszPath[n] == '\\' || lpszPath[n] == '/')
|
|
|
- && (resist & BS_DENY_INHERITED))
|
|
|
+ if(len > n && (lpszPath[n] == '\\' || lpszPath[n] == '/') && (resist & BS_DENY_INHERITED))
|
|
|
{ bForbidden = TRUE; Dbg("forbit1"); }
|
|
|
if(len == n)
|
|
|
{ bForbidden = TRUE; Dbg("forbit2"); }
|
|
|
@@ -2985,7 +2949,9 @@ BOOL ResourceWatcherFSM::InBlackListOrNot(LPCTSTR lpszPath, const int option)
|
|
|
{
|
|
|
FileType ft;
|
|
|
if(IsPathExisted(path.c_str(), ft))
|
|
|
- { bForbidden = TRUE; Dbg("forbit3");}
|
|
|
+ { bForbidden = TRUE;
|
|
|
+ Dbg("forbit3");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -3001,10 +2967,7 @@ BOOL ResourceWatcherFSM::InBlackListOrNot(LPCTSTR lpszPath, const int option)
|
|
|
void ResourceWatcherFSM::InitBlackList()
|
|
|
{
|
|
|
LOG_FUNCTION();
|
|
|
- Dbg("ran at: %s::%d", __FUNCTION__, __LINE__);
|
|
|
- if(!m_forbidDirList.empty())
|
|
|
- m_forbidDirList.clear();
|
|
|
- Dbg("ran at: %s::%d", __FUNCTION__, __LINE__);
|
|
|
+ m_forbidDirList.clear();
|
|
|
DWORD dwDenyAttr;
|
|
|
|
|
|
#if defined(_MSC_VER)
|