Ejemplo n.º 1
0
void vodInit()
{
    int i;
    int code = 0;
    int count = 0;
    if (!vodroot)
        return;
    memset(&vodctx, 0, sizeof(vodctx));
    memset(&charsinfo, 0, sizeof(charsinfo));
    hashmap = calloc(1000000 / 32, sizeof(long));
    //sprintf(vodroot,"%s",hp->pchWebPath);
    cats.name = "";
    cats.hash = GetCategoryHash(&cats);
    cats.next = 0;
    prefixlen = strlen(vodroot) + 1;
    EnumDir(vodroot);

    fpdup = fopen("htdocs/dup.htm", "w");
    fprintf(fpdup, "<html><body>");
    for (i = 0; i < filecount; i++)
    {
        if (!AddClip(filelist[i])) count++;
    }
    fprintf(fpdup, "</body></html>");
    fclose(fpdup);

    printf("\n\nCount: %d\n", count);
}
void EnumDir(CStringA resToken, int nEnumSubdir, std::vector<CString>& vecFiles)
{
	int nEndSlash = resToken.ReverseFind('\\');
	if (nEndSlash == -1)
		return;

	USES_CONVERSION;

	CStringA path = resToken.Mid(0, nEndSlash);
	CStringA findname = resToken.Mid(nEndSlash + 1);

	// file
	WIN32_FIND_DATAA fd;
	memset(&fd, 0, sizeof(WIN32_FIND_DATAA));
	HANDLE hFind = FindFirstFileA(resToken, &fd);

	if (hFind != INVALID_HANDLE_VALUE)
	{
		do
		{
			CStringA subname = fd.cFileName;
			if (subname != "." && subname != "..")
			{
				CStringA fname = path + "\\" + subname;
				if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
				{
				}
				else
					vecFiles.push_back(A2CT(fname));
			}
		} while (FindNextFileA(hFind, &fd) != 0);

		FindClose(hFind);
	}

	// directory
	if (nEnumSubdir > 0)
	{
		hFind = FindFirstFileA(path + "\\*.*", &fd);

		if (hFind != INVALID_HANDLE_VALUE)
		{
			do
			{
				CStringA subname = fd.cFileName;
				if (subname != "." && subname != "..")
				{
					CStringA fname = path + "\\" + subname;
					if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
						EnumDir(fname + "\\" + findname, nEnumSubdir, vecFiles);
				}
			} while (FindNextFileA(hFind, &fd) != 0);

			FindClose(hFind);

		}
	}
}
Ejemplo n.º 3
0
int EnumDir(char* pchDir)
{
    int i;
    char buf[256];
    char* path;
    int dirlen = strlen(pchDir) + 1;
    int pathlen = 0;
    char** dirlist = NULL;
    int dircount = 0;

    for (i = ReadDir(pchDir, buf); !i; i = ReadDir(NULL, buf))
    {
        int len;
        if (buf[0] == '.' && (buf[1] == 0 || (buf[1] == '.' && buf[2] == 0))) continue;
        len = dirlen + strlen(buf) + 1;
        if (len > pathlen)
        {
            if (pathlen) free(path);
            path = malloc(len);
            pathlen = len;
        }
        sprintf(path, "%s/%s", pchDir, buf);
        if (IsDir(path))
        {
            if (!(dircount % PRE_ALLOC_UNIT))
            {
                dirlist = realloc(dirlist, (dircount + PRE_ALLOC_UNIT) * sizeof(char*));
            }
            dirlist[dircount++] = strdup(buf);
        }
        else
        {
            if (!(filecount % PRE_ALLOC_UNIT))
            {
                filelist = realloc(filelist, (filecount + PRE_ALLOC_UNIT) * sizeof(char*));
            }
            filelist[filecount++] = strdup(path + prefixlen);
            //printf("%s\n", path);
        }
    }
    for (i = 0; i < dircount; i++)
    {
        int len = dirlen + strlen(dirlist[i]) + 1;
        if (len > pathlen)
        {
            if (pathlen) free(path);
            path = malloc(len);
            pathlen = len;
        }
        sprintf(path, "%s/%s", pchDir, dirlist[i]);
        free(dirlist[i]);
        EnumDir(path);
    }
    free(dirlist);
    if (pathlen) free(path);
    return 0;
}
Ejemplo n.º 4
0
// Check whether interface description string of Ethernet device can be retrieved in this system
bool EthIsInterfaceDescriptionSupportedUnix()
{
	bool ret = false;
	DIRLIST *d = EnumDir("/etc/sysconfig/networking/devices/");

	if (d == NULL)
	{
		return false;
	}

	if (d->NumFiles >= 1)
	{
		ret = true;
	}

	FreeDir(d);

	return ret;
}
void DoFilePathName(CStringA resToken)
{
	CHAR expName[MAX_PATH + 1];
	ExpandEnvironmentStringsA(resToken, expName, MAX_PATH);
	resToken = expName;

	std::vector<CString>* pvecFiles = new std::vector<CString>;

	if (resToken.Find('*') != -1)
	{
		int nEnumSubdir = 0;
		int nLength = resToken.GetLength();
		if (nLength > 2 && resToken.Mid(nLength - 2).MakeLower() == "|s")
		{
			nEnumSubdir = 1;
			resToken = resToken.Mid(0, nLength - 2);
		}
		else if (nLength > 2 && resToken.Mid(nLength - 2).MakeLower() == "|a")
		{
			nEnumSubdir = 2;
			resToken = resToken.Mid(0, nLength - 2);
		}

		//std::vector<CString> vecFiles;
		EnumDir(resToken, nEnumSubdir, *pvecFiles);
	}
	else
	{
		USES_CONVERSION;

		pvecFiles->push_back(A2W(resToken));
	}

	g_sysModuleNameList.insert(g_sysModuleNameList.end(), (*pvecFiles).begin(), (*pvecFiles).end());
	delete pvecFiles;
}