use of com.intellij.openapi.util.io.win32.FileInfo in project cloudstack by apache.
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) {
List<FileInfo> info = results.getFile();
if (info != null && info.size() > 0) {
s_logger.info("File " + fileFullPath + " exists on datastore");
return true;
}
}
s_logger.info("File " + fileFullPath + " does not exist on datastore");
return false;
}
use of com.intellij.openapi.util.io.win32.FileInfo in project intellij-community by JetBrains.
the class Win32FsCache method getAttributes.
@Nullable
FileAttributes getAttributes(@NotNull VirtualFile file) {
VirtualFile parent = file.getParent();
int parentId = parent instanceof VirtualFileWithId ? ((VirtualFileWithId) parent).getId() : -((VirtualFileWithId) file).getId();
TIntObjectHashMap<THashMap<String, FileAttributes>> map = getMap();
THashMap<String, FileAttributes> nestedMap = map.get(parentId);
String name = file.getName();
FileAttributes attributes = nestedMap != null ? nestedMap.get(name) : null;
if (attributes == null) {
if (nestedMap != null && !(nestedMap instanceof IncompleteChildrenMap)) {
// our info from parent doesn't mention the child in this refresh session
return null;
}
FileInfo info = myKernel.getInfo(file.getPath());
if (info == null) {
return null;
}
attributes = info.toFileAttributes();
if (nestedMap == null) {
nestedMap = new IncompleteChildrenMap<>(FileUtil.PATH_HASHING_STRATEGY);
map.put(parentId, nestedMap);
}
nestedMap.put(name, attributes);
}
return attributes;
}
use of com.intellij.openapi.util.io.win32.FileInfo in project intellij-community by JetBrains.
the class Win32FsCache method list.
@NotNull
String[] list(@NotNull VirtualFile file) {
String path = file.getPath();
FileInfo[] fileInfo = myKernel.listChildren(path);
if (fileInfo == null || fileInfo.length == 0) {
return ArrayUtil.EMPTY_STRING_ARRAY;
}
String[] names = new String[fileInfo.length];
TIntObjectHashMap<THashMap<String, FileAttributes>> map = getMap();
int parentId = ((VirtualFileWithId) file).getId();
THashMap<String, FileAttributes> nestedMap = map.get(parentId);
if (nestedMap == null) {
nestedMap = new THashMap<>(fileInfo.length, FileUtil.PATH_HASHING_STRATEGY);
map.put(parentId, nestedMap);
}
for (int i = 0, length = fileInfo.length; i < length; i++) {
FileInfo info = fileInfo[i];
String name = info.getName();
nestedMap.put(name, info.toFileAttributes());
names[i] = name;
}
return names;
}
use of com.intellij.openapi.util.io.win32.FileInfo in project intellij-community by JetBrains.
the class FileAttributesReadingTest method getAttributes.
@NotNull
private static FileAttributes getAttributes(@NotNull final File file, final boolean checkList) {
final FileAttributes attributes = FileSystemUtil.getAttributes(file);
assertNotNull(attributes);
if (SystemInfo.isWindows && checkList) {
final String parent = file.getParent();
if (parent != null) {
final FileInfo[] infos = IdeaWin32.getInstance().listChildren(parent);
assertNotNull(infos);
for (FileInfo info : infos) {
if (file.getName().equals(info.getName())) {
assertEquals(attributes, info.toFileAttributes());
return attributes;
}
}
fail(file + " not listed");
}
}
return attributes;
}
use of com.intellij.openapi.util.io.win32.FileInfo in project cloudstack by apache.
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) {
List<FileInfo> info = results.getFile();
if (info != null && info.size() > 0) {
s_logger.info("Folder " + folderName + " exists on datastore");
return true;
}
}
s_logger.info("Folder " + folderName + " does not exist on datastore");
return false;
}
Aggregations