示例#1
0
bool SnapLog::Impl::FindNValidSnapshots(uint32 count,
                                        list<string> *files) const {
  if (!SortFiles(log_dir_, "snap", false, files)) {
    return false;
  }
  return true;
}
示例#2
0
int ListDirectory(ClientData nulldata, Tcl_Interp *interp, int argc,
		  char **argv)
{
    struct dirent *dp;
    struct stat stbuf;
    char command[256];
    char fileName[MAX_FILES][MAX_NAME_LEN];
    boolean dirList[MAX_FILES];
    int permute[MAX_FILES];
    int	fileCount = 0;
    register int index;
    char fullName[MAXPATHLEN];
    char    *restPtr;

    sprintf(command, "ShowCurrentDirectory %s", currentPath);
    Tcl_Eval(interp, command, 0, (char **) NULL);

    if ( dfd == NULL )
    {
	fprintf(stderr, "TRIED TO LIST NULL DIRECTORY\n");

	return TCL_OK;
    }

/* check if root directory */
    if ( strlen(currentPath) != 1 )
    {
	sprintf(fileName[fileCount], "../");
	dirList[fileCount] = TRUE;
	fileCount++;
    }

    strcpy(fullName, currentPath);
    restPtr = &fullName[strlen(fullName)];

    while ( (dp = readdir(dfd)) != NULL )
    {
	strcpy(restPtr, dp->d_name);
	stat(fullName, &stbuf);

	if ( dp->d_name[0] != '.' )
	{
	    if ( S_ISDIR(stbuf.st_mode) )
	    {
		sprintf(fileName[fileCount], "%s/", dp->d_name);
		dirList[fileCount] = TRUE;
		fileCount++;
	    }
	    else
	    {
		if ( MatchesGlob(dp->d_name, globString) )
		{
		    strcpy(fileName[fileCount], dp->d_name);
		    dirList[fileCount] = FALSE;
		    fileCount++;
		}
	    }
	}
    }

    SortFiles(fileCount, fileName, dirList, permute);

    for ( index = 0; index < fileCount; index++ )
    {
	sprintf(command, "AddBrowseFile %s", fileName[permute[index]]);
	Tcl_Eval(interp, command, 0, (char **) NULL);
    }

    closedir(dfd);

    return TCL_OK;
}