Example #1
0
void Utils::DeletePath(CString sPath)
{
	CFileFind tempFind;    
	bool IsFinded = tempFind.FindFile(sPath + "\\*.*");    
	while (IsFinded)    
	{    
		IsFinded = tempFind.FindNextFile();    
		//当这个目录中不含有.的时候,就是说这不是一个文件。  
		if (!tempFind.IsDots())    
		{    
			char sFoundFileName[200];     
			strcpy(sFoundFileName,tempFind.GetFileName().GetBuffer(200));  
			//如果是目录那么删除目录  
			if (tempFind.IsDirectory())    
			{     
				char sTempDir[200];       
				sprintf(sTempDir,"%s\\%s",sPath,sFoundFileName);    
				DeletePath(sTempDir); //其实真正删除文件的也就这两句,别的都是陪衬  
			}    
			//如果是文件那么删除文件  
			else      
			{     
				char sTempFileName[200];      
				sprintf(sTempFileName,"%s\\%s",sPath,sFoundFileName);    
				DeleteFile(sTempFileName);    
			}    
		}    
	}    
	tempFind.Close();
	RemoveDirectory(sPath);
}
Example #2
0
/* unlink
 * The is the ANSI C file 
 * deletion method and is shared by the 'modern' */
int unlink(
	_In_ const char *path) {
	if (path == NULL) {
		_set_errno(EINVAL);
		return EOF;
	}
	return _fval(DeletePath(path, 0));
}
Example #3
0
void DeinitPathFinder(PathFinder* pathFinder)
{
    DeleteQueue(pathFinder->openList);
    for (int i = 0; i < pathFinder->map->width; ++i)
        free(pathFinder->nodeMap[i]);
    free(pathFinder->nodeMap);

    DeletePath(pathFinder);
}
Example #4
0
void _TestUpk()
{
	LPCTSTR szExeFile = _T("O:\\office\\2003\\ksafe_office2003-KB951535-FullFile-CHS.exe");
	LPCTSTR szExtractPath = _T("C:\\Program Files\\masdfasdf");
	DeletePath(szExtractPath);

	Files files;
	TRUE ? ExtractOfficePackage(szExeFile, szExtractPath, files) : UpkUse7z(szExeFile, szExtractPath, files);
	DumpFiles(files);
}
Example #5
0
    void fini()
    {
        gfx::gpu_timer_fini(&gpuTimer);

        struct DeletePath
        {void operator ()(vg::Path path) {vg::destroyPath(path);}};

        for_each(mPaths.begin(), mPaths.end(), DeletePath());

        struct DeletePaint
        {void operator ()(vg::Paint paint) {vg::destroyPaint(paint);}};

        for_each(mPaints.begin(), mPaints.end(), DeletePaint());
    }
Example #6
0
static HRESULT CALLBACK OpenList_Open (
   POPENLIST_FILE polf,
   LPARAM         lArgs)
{
   HRESULT hr = S_OK;

   if (E_CANCEL != polf->hr)  // Possible if a queue'd open was canceled on progman and we are being called for possible batch undo handling
      {
      hr = E_FILE_UNSUPPORTED;

      if (g_app.fDiagnostic)
         bprintfl("\nDeletePath \"%s\" recursive = %d", polf->szPathName, g_app.fSubDirs);

      DWORD fdwTraverse = 0;
      if (g_app.fSubDirs)     fdwTraverse |= TDT_SUBDIRS;
      //if (g_app.fNoFiles)   fdwTraverse |= TDT_NOFILES;
      //if (g_app.fNoDirs)    fdwTraverse |= TDT_NODIRS;
      if (g_app.fContinue)    fdwTraverse |= TDT_CONTINUE;
      if (g_app.fDiagnostic)  fdwTraverse |= TDT_DIAGNOSTIC;

      DWORD fdwSecurity = 0;
      if (g_app.fNoDelete) fdwSecurity = DP_S_NODELETE;

      DWORD fdwVerbose = 0;
      if (g_app.fVerbose)     fdwVerbose |= DP_V_VERBOSE;
      if (g_app.fDiagnostic)  fdwVerbose |= DP_V_DIAGNOSTIC;
      if (g_app.fQuiet)       fdwVerbose |= DP_V_QUIET;

      int err = DeletePath(polf->szPathName, TEXT(""), fdwTraverse, fdwSecurity, fdwVerbose, g_bprint);

      //  DeletePath has already reported errors.
      /*
      if (err && ERROR_NO_MORE_FILES != err)
         {
         TCHAR szErr[MAX_PATH];
         if (GetLastErrorText(err, szErr, NUMCHARS(szErr)) <= 0)
            wsprintf(szErr, TEXT("Error %d"), err);
         bprintfl ("%s\n", szErr);
         }
      */
      if (g_app.fContinue)
         hr = S_OK;
      else if (err)
         hr = E_CANCEL;
      }

   return hr;
}
Example #7
0
int main(int argc, char* argv[])
{
	if (argc <= 1) {
		return 0;
	}
/*
	if (CreatePath(argv[1], 0766) == false) {
		fprintf(stderr, "create path failed\n");
		return 1;
	}
*/

	if (DeletePath(argv[1]) == false) {
		fprintf(stderr, "delete path failed\n");
		return 1;
	}

	return 0;
}
Example #8
0
bool DeletePath(const char* a_szPath)
{
	if (a_szPath == NULL) {
		return false;
	}
	DIR* pDir = opendir(a_szPath);
	if (pDir == NULL) {
		if (errno == ENOENT) {
			return true;
		}
		return false;
	}

	struct dirent *pEnt = NULL;
	struct stat stFileInfo;
	char szAbsFileName[FILENAME_MAX] = {0x00,};

	while (true) {
        pEnt = readdir(pDir);
        if (pEnt == NULL) {
            break;
        }
		snprintf(szAbsFileName, sizeof(szAbsFileName), "%s/%s", a_szPath, pEnt->d_name);
		if (lstat(szAbsFileName, &stFileInfo) < 0) {
			return false;
		}
		if (S_ISDIR(stFileInfo.st_mode)) {
			if(strcmp(pEnt->d_name, ".") && strcmp(pEnt->d_name, "..")) {
				DeletePath(szAbsFileName);
			}
		} else {
			remove(szAbsFileName);
		}
	}
	closedir(pDir);

	remove(a_szPath);

	return true;
}
Example #9
0
void PathMan::DeleteAllPaths( void )
{
    ::wxBeginBusyCursor();

    //    Iterate on the RouteList
    wxPathListNode *node = g_pPathList->GetFirst();
    while( node ) {
        ODPath *ppath = node->GetData();
        if( ppath->m_bIsInLayer ) {
            node = node->GetNext();
            continue;
        }

//        g_pODConfig->m_bSkipChangeSetUpdate = true;
        DeletePath( ppath );
        node = g_pPathList->GetFirst();                   // Path
//        g_pODConfig->m_bSkipChangeSetUpdate = false;
    }

    ::wxEndBusyCursor();

}
Example #10
0
void FindPath(PathFinder* pf)
{
    //printf("(%d, %d) -> (%d, %d)\t", pf->startx, pf->starty, pf->endx, pf->endy);
    for (int i = 0; i < pf->map->width; i++)
    {
        for (int e = 0; e < pf->map->height; e++)
        {
            pf->nodeMap[i][e].f = 0;
            pf->nodeMap[i][e].g = 0;
            pf->nodeMap[i][e].h = 0;
            pf->nodeMap[i][e].open = NoList;
            pf->nodeMap[i][e].parent = NULL;
        }
    }
    DeleteQueue(pf->openList);
    pf->openList = CreateQueue(nodeMinCompare, pf->map->width * pf->map->height);

    int x = pf->startx;
    int y = pf->starty;

    // Step 1: Add starting node to the open list.
    AddOpen(pf, x, y, NULL);

    // Step 2: Repeat
    // If there's nothing in the open list anymore or we arrive at the destination, stop
    while (GetQueueSize(pf->openList) > 0)
    {
        //printf("%d ", GetQueueSize(pf->openList));
        // a) Look for the lowest F cost square on the open list.
        Node* current = (Node*)QueueRemove(pf->openList);

        x = current->x;
        y = current->y;

        // b) Switch it to the closed list.
        current->open = OnClosedList;

        // c) For each of the 8 squares adjacent to this current square, attempt to add it
        //    to the open list.
        // AddOpen checks for adjacent-validity and whether the node is a wall or not.
        AddOpen(pf, x - 0, y - 1, current);
        AddOpen(pf, x - 0, y + 1, current);
        AddOpen(pf, x - 1, y - 0, current);
        AddOpen(pf, x + 1, y - 0, current);

        // Diagonal Check
        if (pf->allowDiagonal)
        {
            AddOpen(pf, x - 1, y - 1, current);
            AddOpen(pf, x + 1, y - 1, current);
            AddOpen(pf, x - 1, y + 1, current);
            AddOpen(pf, x + 1, y + 1, current);
        }

        // Are we done?
        if (x == pf->endx && y == pf->endy &&
            pf->nodeMap[pf->endx][pf->endy].open == OnClosedList)
        {
            // Step 3: Save Path
            DeletePath(pf);
            SavePath(pf, current);

            /*
            PathNode* p = pf->path;
            if (p == NULL)
                printf(" No Path?");
            while (p)
            {
                printf("(%p) %d, %d", p, p->x, p->y);
                p = p->parent;
            }
            */
            break;
        }
    }
    printf("Pathfinding done\n");
}