本文整理汇总了C#中Path.toString方法的典型用法代码示例。如果您正苦于以下问题:C# Path.toString方法的具体用法?C# Path.toString怎么用?C# Path.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path.toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: listStatus
public FileStatus[] listStatus(Path path) {
path = path.makeQualified(this);
List<FileStatus> result = new ArrayList<FileStatus>();
String pathname = path.toString();
String pathnameAsDir = pathname + "/";
Set<String> dirs = new TreeSet<String>();
for(MockFile file: files) {
String filename = file.path.toString();
if (pathname.equals(filename)) {
return new FileStatus[]{createStatus(file)};
} else if (filename.startsWith(pathnameAsDir)) {
String tail = filename.substring(pathnameAsDir.length());
int nextSlash = tail.indexOf('/');
if (nextSlash > 0) {
dirs.add(tail.substring(0, nextSlash));
} else {
result.add(createStatus(file));
}
}
}
// for each directory add it once
for(String dir: dirs) {
result.add(createDirectory(new MockPath(this, pathnameAsDir + dir)));
}
return result.toArray(new FileStatus[result.size()]);
}
示例2: getFileStatus
public FileStatus getFileStatus(Path path) {
path = path.makeQualified(this);
String pathnameAsDir = path.toString() + "/";
for(MockFile file: files) {
if (file.path.equals(path)) {
return createStatus(file);
} else if (file.path.toString().startsWith(pathnameAsDir)) {
return createDirectory(path);
}
}
throw new FileNotFoundException("File " + path + " does not exist");
}
示例3: create
public FSDataOutputStream create(Path path, FsPermission fsPermission,
bool overwrite, int bufferSize,
short replication, long blockSize,
Progressable progressable
) {
MockFile file = null;
for(MockFile currentFile: files) {
if (currentFile.path.equals(path)) {
file = currentFile;
break;
}
}
if (file == null) {
file = new MockFile(path.toString(), (int) blockSize, new byte[0]);
files.add(file);
}
return new MockOutputStream(file);
}