Search in sources :

Example 1 with FileInfo

use of com.intellij.openapi.util.io.win32.FileInfo in project CloudStack-archive by CloudStack-extras.

the class DatastoreMO method fileExists.

public boolean fileExists(String fileFullPath) throws Exception {
    DatastoreFile file = new DatastoreFile(fileFullPath);
    DatastoreFile dirFile = new DatastoreFile(file.getDatastoreName(), file.getDir());
    HostDatastoreBrowserMO browserMo = getHostDatastoreBrowserMO();
    s_logger.info("Search file " + file.getFileName() + " on " + dirFile.getPath());
    HostDatastoreBrowserSearchResults results = browserMo.searchDatastore(dirFile.getPath(), file.getFileName(), true);
    if (results != null) {
        FileInfo[] info = results.getFile();
        if (info != null && info.length > 0) {
            s_logger.info("File " + fileFullPath + " exists on datastore");
            return true;
        }
    }
    s_logger.info("File " + fileFullPath + " does not exist on datastore");
    return false;
/*		
		String[] fileNames = listDirContent(dirFile.getPath());
		
		String fileName = file.getFileName();
		for(String name : fileNames) {
			if(name.equalsIgnoreCase(fileName))
				return true;
		} 
		
		return false;
*/
}
Also used : HostDatastoreBrowserSearchResults(com.vmware.vim25.HostDatastoreBrowserSearchResults) FileInfo(com.vmware.vim25.FileInfo)

Example 2 with FileInfo

use of com.intellij.openapi.util.io.win32.FileInfo in project CloudStack-archive by CloudStack-extras.

the class DatastoreMO method folderExists.

public boolean folderExists(String folderParentDatastorePath, String folderName) throws Exception {
    HostDatastoreBrowserMO browserMo = getHostDatastoreBrowserMO();
    HostDatastoreBrowserSearchResults results = browserMo.searchDatastore(folderParentDatastorePath, folderName, true);
    if (results != null) {
        FileInfo[] info = results.getFile();
        if (info != null && info.length > 0) {
            s_logger.info("Folder " + folderName + " exists on datastore");
            return true;
        }
    }
    s_logger.info("Folder " + folderName + " does not exist on datastore");
    return false;
}
Also used : HostDatastoreBrowserSearchResults(com.vmware.vim25.HostDatastoreBrowserSearchResults) FileInfo(com.vmware.vim25.FileInfo)

Example 3 with FileInfo

use of com.intellij.openapi.util.io.win32.FileInfo in project intellij-community by JetBrains.

the class IdeaWin32PerformanceTest method doTest.

private void doTest(File file) {
    String path = file.getPath();
    long t1 = System.nanoTime();
    File[] children1 = file.listFiles();
    long t2 = System.nanoTime();
    FileInfo[] children2 = myDriver.listChildren(path);
    long t3 = System.nanoTime();
    myJavaTotal += (t2 - t1) / 1000;
    myIdeaTotal += (t3 - t2) / 1000;
    assertNotNull(path, children1);
    assertNotNull(path, children2);
    assertEquals(path, children1.length, children2.length);
    for (File child : children1) {
        if (child.isDirectory()) {
            doTest(child);
        }
    }
}
Also used : FileInfo(com.intellij.openapi.util.io.win32.FileInfo) File(java.io.File)

Example 4 with FileInfo

use of com.intellij.openapi.util.io.win32.FileInfo in project cloudstack by apache.

the class VmwareStorageManagerImpl method getVMSnapshotChainSize.

private long getVMSnapshotChainSize(VmwareContext context, VmwareHypervisorHost hyperHost, String fileName, ManagedObjectReference morDs, String exceptFileName, String vmName) throws Exception {
    long size = 0;
    DatastoreMO dsMo = new DatastoreMO(context, morDs);
    HostDatastoreBrowserMO browserMo = dsMo.getHostDatastoreBrowserMO();
    String datastorePath = (new DatastoreFile(dsMo.getName(), vmName)).getPath();
    HostDatastoreBrowserSearchSpec searchSpec = new HostDatastoreBrowserSearchSpec();
    FileQueryFlags fqf = new FileQueryFlags();
    fqf.setFileSize(true);
    fqf.setFileOwner(true);
    fqf.setModification(true);
    searchSpec.setDetails(fqf);
    searchSpec.setSearchCaseInsensitive(false);
    searchSpec.getMatchPattern().add(fileName);
    ArrayList<HostDatastoreBrowserSearchResults> results = browserMo.searchDatastoreSubFolders(datastorePath, searchSpec);
    for (HostDatastoreBrowserSearchResults result : results) {
        if (result != null) {
            List<FileInfo> info = result.getFile();
            for (FileInfo fi : info) {
                if (exceptFileName != null && fi.getPath().contains(exceptFileName)) {
                    continue;
                } else {
                    size = size + fi.getFileSize();
                }
            }
        }
    }
    return size;
}
Also used : HostDatastoreBrowserMO(com.cloud.hypervisor.vmware.mo.HostDatastoreBrowserMO) HostDatastoreBrowserSearchResults(com.vmware.vim25.HostDatastoreBrowserSearchResults) FileInfo(com.vmware.vim25.FileInfo) DatastoreFile(com.cloud.hypervisor.vmware.mo.DatastoreFile) HostDatastoreBrowserSearchSpec(com.vmware.vim25.HostDatastoreBrowserSearchSpec) FileQueryFlags(com.vmware.vim25.FileQueryFlags) DatastoreMO(com.cloud.hypervisor.vmware.mo.DatastoreMO)

Example 5 with FileInfo

use of com.intellij.openapi.util.io.win32.FileInfo in project cloudstack by apache.

the class DatastoreMO method fileDiskSize.

public long fileDiskSize(String fileFullPath) throws Exception {
    long size = 0;
    DatastoreFile file = new DatastoreFile(fileFullPath);
    DatastoreFile dirFile = new DatastoreFile(file.getDatastoreName(), file.getDir());
    HostDatastoreBrowserMO browserMo = getHostDatastoreBrowserMO();
    HostDatastoreBrowserSearchSpec searchSpec = new HostDatastoreBrowserSearchSpec();
    FileQueryFlags fqf = new FileQueryFlags();
    fqf.setFileSize(true);
    fqf.setFileOwner(true);
    fqf.setFileType(true);
    fqf.setModification(true);
    searchSpec.setDetails(fqf);
    searchSpec.setSearchCaseInsensitive(false);
    searchSpec.getMatchPattern().add(file.getFileName());
    // ROOT-2.vmdk, [3ecf7a579d3b3793b86d9d019a97ae27] s-2-VM
    s_logger.debug("Search file " + file.getFileName() + " on " + dirFile.getPath());
    HostDatastoreBrowserSearchResults result = browserMo.searchDatastore(dirFile.getPath(), searchSpec);
    if (result != null) {
        List<FileInfo> info = result.getFile();
        for (FileInfo fi : info) {
            if (file.getFileName().equals(fi.getPath())) {
                s_logger.debug("File found = " + fi.getPath() + ", size=" + toHumanReadableSize(fi.getFileSize()));
                return fi.getFileSize();
            }
        }
    }
    s_logger.debug("File " + fileFullPath + " does not exist on datastore");
    return size;
}
Also used : HostDatastoreBrowserSearchResults(com.vmware.vim25.HostDatastoreBrowserSearchResults) FileInfo(com.vmware.vim25.FileInfo) HostDatastoreBrowserSearchSpec(com.vmware.vim25.HostDatastoreBrowserSearchSpec) FileQueryFlags(com.vmware.vim25.FileQueryFlags)

Aggregations

FileInfo (com.vmware.vim25.FileInfo)8 HostDatastoreBrowserSearchResults (com.vmware.vim25.HostDatastoreBrowserSearchResults)8 FileInfo (com.intellij.openapi.util.io.win32.FileInfo)4 FileAttributes (com.intellij.openapi.util.io.FileAttributes)2 VirtualFileWithId (com.intellij.openapi.vfs.VirtualFileWithId)2 FileQueryFlags (com.vmware.vim25.FileQueryFlags)2 HostDatastoreBrowserSearchSpec (com.vmware.vim25.HostDatastoreBrowserSearchSpec)2 THashMap (gnu.trove.THashMap)2 NotNull (org.jetbrains.annotations.NotNull)2 CloudException (com.cloud.exception.CloudException)1 DatastoreFile (com.cloud.hypervisor.vmware.mo.DatastoreFile)1 DatastoreMO (com.cloud.hypervisor.vmware.mo.DatastoreMO)1 HostDatastoreBrowserMO (com.cloud.hypervisor.vmware.mo.HostDatastoreBrowserMO)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Nullable (org.jetbrains.annotations.Nullable)1 Before (org.junit.Before)1