Directory Listing

From ParaQ Wiki
Jump to navigationJump to search

Overview

This document descrides the mechanism for obtaining a server (or client) side directory listing from the Server Manager. This used to be done using vtkSMServerFileListingProxy, however the API was slow and clumpsy. It is now deprecated and is replaced by vtkPVFileInformation which is a vtkPVInformation subclass which can be gathered just like other information objects.

Usage

  • Create vtkPVFileInformationHelper on the server (or client) from which we want to get the directory listing. One can create a vtkPVFileInformationHelper proxy using:
vtkSMProxy helper = vtkSMProxyManager::GetProxyManager()->NewProxy("misc", "FileInformationHelper");
  • vtkPVFileInformationHelper has properties such as:
    • Path (string) :- path which we want to get information about.
    • DirectoryListing (bool) :- when set a directory listing is obtained in case Path is a directory.
    • SpecialDirectories (bool) :- when set Path and DirecoryListing are ignored, instead a listing of special directories on the server such as My Documents, Home etc. are obtained.
    • FastFileTypeDetection (bool) :- Used when obtaining directory listing. If filenames matching a particular pattern are detected, we query the system only for the file type of the first file in that sequence and assume that all others in that group have the same type.
  • Then create a vtkPVFileInformation object and request a gather.
 vtkPVFileInformation* info = vtkPVFileInformation::New();
 vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
 pm->GatherInformation(/* connection Id */, /* server flags */, info, helper->GetID(0));
  • Information about the Path will be available in info. If DirectoryListing was 1 on the helper and Path is a directory, then info->GetContents() will return a vtkCollection of vtkPVFileInformation objects for all the files/directories in the Path.
  • If SpecialDirectories is true, info itself is of Type=INVALID, but info->GetContents() will be collection of information objects for all special directories and drives.
  • To obtain local file system information one can do the following:
 vtkPVFileInformationHelper *helper = vtkPVFileInformationHelper::New();
 /* set default values */
 vtkPVFileInformation* info = vtkPVFileInformation::New();
 info->CopyFromObject(helper);
 /* info will now have the file information/directory listing. */