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;
*/
}
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;
}
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);
}
}
}
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;
}
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;
}
Aggregations