nsresult nsAbDirectoryQuery::queryChildren(nsIAbDirectory* directory,
                                           nsIAbBooleanExpression* expression,
                                           nsIAbDirSearchListener* listener,
                                           bool doSubDirectories,
                                           PRInt32* resultLimit)
{
    nsresult rv = NS_OK;

    nsCOMPtr<nsISimpleEnumerator> subDirectories;
    rv = directory->GetChildNodes(getter_AddRefs(subDirectories));
    NS_ENSURE_SUCCESS(rv, rv);

    bool hasMore;
    while (NS_SUCCEEDED(rv = subDirectories->HasMoreElements(&hasMore)) && hasMore)
    {
        nsCOMPtr<nsISupports> item;
        rv = subDirectories->GetNext (getter_AddRefs (item));
        NS_ENSURE_SUCCESS(rv, rv);

        nsCOMPtr<nsIAbDirectory> subDirectory(do_QueryInterface(item, &rv));
        NS_ENSURE_SUCCESS(rv, rv);
        
        rv = query(subDirectory, expression, listener, doSubDirectories, resultLimit);
        NS_ENSURE_SUCCESS(rv, rv);

    }
    return NS_OK;
}
void CMMCScBkupReadDataTransferRequestBase::DumpTransferDataL( RFs& aFsSession, const TDesC8& aData ) const
    {
    TPtrC subDirectory( KNullDesC );
    //
    switch( ElementType() )
        {
    case EMMCScBkupOwnerDataTypeJavaData:
        subDirectory.Set(KMMCScBkupDataTransferDebuggingPathDataJava);
        break;
    case EMMCScBkupOwnerDataTypeSystemData:
        subDirectory.Set(KMMCScBkupDataTransferDebuggingPathDataSystem);
        break;
    case EMMCScBkupOwnerDataTypePassiveData:
        subDirectory.Set(KMMCScBkupDataTransferDebuggingPathDataPassive);
        break;
    case EMMCScBkupOwnerDataTypeActiveData:
        subDirectory.Set(KMMCScBkupDataTransferDebuggingPathDataActive);
        break;
    default:
        User::Leave( KErrNotSupported );
        break;
        }
    //
    const TSecureId secureId = DataOwner().SecureId();
    _LIT(KMMCScBkupFormatDes, "%S%S");
    TFileName transferDumpFileName;
    const TDesC& path = PathInfo::MemoryCardRootPath();
    transferDumpFileName.Format(KMMCScBkupFormatDes, &path, &KMMCScBkupDataTransferDebuggingPathRoot);
    
    transferDumpFileName.Append( subDirectory );
    transferDumpFileName.Append( KMMCScBkupDataTransferDebuggingPathDataRestore );
    transferDumpFileName.AppendFormat( KMMCScBkupDataTransferDebuggingFileName, secureId.iId, 'a' + CurrentDrive() );
    //
    RFile64 file;
    TInt error = KErrNone;
    TEntry entry;
    if  ( aFsSession.Entry( transferDumpFileName, entry ) == KErrNone )
        {
        // Already exists - append data
        error = file.Open( aFsSession, transferDumpFileName, EFileWrite | EFileStream | EFileShareExclusive );
        }
    else
        {
        entry.iSize = 0;
        error = file.Create( aFsSession, transferDumpFileName, EFileWrite | EFileStream | EFileShareExclusive );
        }
    //
    User::LeaveIfError( error );
    CleanupClosePushL( file );
    error = file.Write( entry.iSize, aData );
    CleanupStack::PopAndDestroy( &file );
    }
예제 #3
0
파일: main.c 프로젝트: robm123/Indexer
// recursively calls itself if the pointer reaches another directory
void subDirectory(char* sub, char* fullPath, SortedListPtr list)
{
	char subdirectory[999];
	char current[999];
	
	struct dirent* pD;
	DIR* dir2;
	
	strcpy(subdirectory, sub);
	strcpy(current, fullPath);
	strcat((strcat(current,"/")),subdirectory); 
	dir2 = opendir(current);

	if(dir2 == NULL)
		printf("*****\n\nCould not open directory:   \n%s\n", current);

	pD = readdir(dir2);
	
	while(pD != NULL)
	{	
		if(pD->d_type == DT_REG)
		{
			char fn2[9999];	
			strcpy(fn2, current);
			strcat(strcat(fn2,"/"),pD->d_name);		
	
			
			char *sv = fn2; 
			strcpy(charptr[i], sv);
			printf("About to open file: %s\n",charptr[i]);				
			readprocess(charptr[i], list);			
			i++;			
		}
	    if(pD->d_type == DT_DIR && strcmp(pD->d_name, ".") != 0  && strcmp(pD->d_name, "..") != 0 )
		{														  												             
			subDirectory(pD->d_name, current, list);
		}
		
		pD = readdir(dir2);	
	}
	closedir(dir2);
	return;
}
예제 #4
0
파일: main.c 프로젝트: robm123/Indexer
int main(int argc, char **argv)  
{
  
	char *outputFile = argv[1]; 
	char *pathName = argv[2];	
	char ans[0];
	char strp[999];		 
	struct stat status;
	struct dirent *pDirent;
	//struct dirent *ini;
	DIR* dir;
	SortedListPtr list = SLCreate(compareStrings);	
	int st = 0;

	if(argc != 3)
	{
		printf("Incorrect amount of arguments");
		return 0;
	}

	FILE *ofp;
	ofp = fopen(outputFile, "w");
	if(!ofp)
	{
		perror("Cannot open output file");
		exit(EXIT_FAILURE);
	}
	
	st = stat(pathName,&status);	
	if(st != 0)
	{
		printf("Error");
		return 1;
	}
	
	if(S_ISREG(status.st_mode))
	{		
		readprocess(pathName, list);
		outputAll(list, ofp, pathName);
		fclose(ofp);						
		return 1;
	}

	dir = opendir(pathName); //returns pointer to stream
	
	if(dir == NULL)
		printf("Could not open directory: %s\n", pathName);
	else
		printf("\nWe are inside:  %s \n", pathName);
			
	char *currentPath = malloc(strlen(pathName)+1);	
	currentPath = pathName;

	pDirent = readdir(dir);
	 
	while(pDirent != NULL)
	{	
		if(pDirent->d_type == DT_REG)
		{
			char thePath[9999];
			strcpy(thePath, currentPath);
			strcat(strcat(thePath,"/"),pDirent->d_name);

			char *sv = thePath; 
			strcpy(charptr[i], sv);
			readprocess(charptr[i], list);			
			i++;
		}
		if(pDirent->d_type == DT_DIR && strcmp(pDirent->d_name, ".") != 0  && strcmp(pDirent->d_name, "..") != 0 )
		{															  	
			//printf("%s\n\n", pDirent->d_name);													
			subDirectory(pDirent->d_name, currentPath, list);
	
		}

		pDirent = readdir(dir);	
	}
	//closes parent directory
	closedir(dir);
	
//-=-=-=-=--=-==-=-=-==-THIS WILL OUTPUT TO FILE-=-=--=-==-=-=-==-==--=-=	

	//pass the list and print it 
	outputAll(list, ofp, pathName);
	fclose(ofp);
	printf("Goodbye\n");
//-=-=-=-=-=-=--=-==-=-=-=-=-=-=--=-==-=-=-==-==--=-=-===-==-=-=-=-==-=-=-	
	return 0;
}