本文整理汇总了Java中io.vertx.core.file.FileProps类的典型用法代码示例。如果您正苦于以下问题:Java FileProps类的具体用法?Java FileProps怎么用?Java FileProps使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileProps类属于io.vertx.core.file包,在下文中一共展示了FileProps类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: readFile
import io.vertx.core.file.FileProps; //导入依赖的package包/类
public static Future<LocalFile> readFile(FileSystem fs, String filefullPathName) {
LocalFile localFile = new LocalFile();
return Future.<FileProps>future(future -> {
fs.props(filefullPathName, future);
}).compose(props -> {
localFile.setSize(props.size());
return Future.<AsyncFile>future(future -> {
fs.open(filefullPathName, new OpenOptions().setRead(true).setWrite(false).setCreate(false), future);
});
}).compose(fileStream -> {
localFile.setFile(fileStream);
return Future.succeededFuture(localFile);
});
}
开发者ID:gengteng,项目名称:vertx-fastdfs-client,代码行数:19,代码来源:FdfsStorageImpl.java
示例2: ls
import io.vertx.core.file.FileProps; //导入依赖的package包/类
void ls(Vertx vertx, String currentFile, String pathArg, Handler<AsyncResult<Map<String, FileProps>>> filesHandler) {
Path base = currentFile != null ? new File(currentFile).toPath() : rootDir;
String path = base.resolve(pathArg).toAbsolutePath().normalize().toString();
vertx.executeBlocking(fut -> {
FileSystem fs = vertx.fileSystem();
if (fs.propsBlocking(path).isDirectory()) {
LinkedHashMap<String, FileProps> result = new LinkedHashMap<>();
for (String file : fs.readDirBlocking(path)) {
result.put(file, fs.propsBlocking(file));
}
fut.complete(result);
} else {
throw new RuntimeException(path + ": No such file or directory");
}
}, filesHandler);
}
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:17,代码来源:FsHelper.java
示例3: testReportToFile
import io.vertx.core.file.FileProps; //导入依赖的package包/类
@org.junit.Test
public void testReportToFile() {
FileSystem fs = vertx.fileSystem();
String file = "target";
assertTrue(fs.existsBlocking(file));
assertTrue(fs.propsBlocking(file).isDirectory());
suite.run(vertx, new TestOptions().addReporter(new ReportOptions().setTo("file:" + file)));
String path = file + File.separator + "my_suite.txt";
assertTrue(fs.existsBlocking(path));
int count = 1000;
while (true) {
FileProps props = fs.propsBlocking(path);
if (props.isRegularFile() && props.size() > 0) {
break;
} else {
if (count-- > 0) {
try {
Thread.sleep(1);
} catch (InterruptedException ignore) {
}
} else {
fail();
}
}
}
}
开发者ID:vert-x3,项目名称:vertx-unit,代码行数:27,代码来源:ReportingTest.java
示例4: writeCacheHeaders
import io.vertx.core.file.FileProps; //导入依赖的package包/类
/**
* Create all required header so content can be cache by Caching servers or Browsers
*
* @param request base HttpServerRequest
* @param props file properties
*/
private void writeCacheHeaders(HttpServerRequest request, FileProps props) {
MultiMap headers = request.response().headers();
if (cachingEnabled) {
// We use cache-control and last-modified
// We *do not use* etags and expires (since they do the same thing - redundant)
headers.set("cache-control", "public, max-age=" + maxAgeSeconds);
headers.set("last-modified", dateTimeFormatter.format(props.lastModifiedTime()));
// We send the vary header (for intermediate caches)
// (assumes that most will turn on compression when using static handler)
if (sendVaryHeader && request.headers().contains("accept-encoding")) {
headers.set("vary", "accept-encoding");
}
}
// date header is mandatory
headers.set("date", dateTimeFormatter.format(new Date()));
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:26,代码来源:StaticHandlerImpl.java
示例5: getOne
import io.vertx.core.file.FileProps; //导入依赖的package包/类
@Override
public void getOne(String path, Handler<AsyncResult<ChunkReadStream>> handler) {
String absolutePath = Paths.get(root, path).toString();
// check if chunk exists
FileSystem fs = vertx.fileSystem();
ObservableFuture<Boolean> observable = RxHelper.observableFuture();
fs.exists(absolutePath, observable.toHandler());
observable
.flatMap(exists -> {
if (!exists) {
return Observable.error(new FileNotFoundException("Could not find chunk: " + path));
}
return Observable.just(exists);
})
.flatMap(exists -> {
// get chunk's size
ObservableFuture<FileProps> propsObservable = RxHelper.observableFuture();
fs.props(absolutePath, propsObservable.toHandler());
return propsObservable;
})
.map(props -> props.size())
.flatMap(size -> {
// open chunk
ObservableFuture<AsyncFile> openObservable = RxHelper.observableFuture();
OpenOptions openOptions = new OpenOptions().setCreate(false).setWrite(false);
fs.open(absolutePath, openOptions, openObservable.toHandler());
return openObservable.map(f -> new FileChunkReadStream(size, f));
})
.subscribe(readStream -> {
// send chunk to peer
handler.handle(Future.succeededFuture(readStream));
}, err -> {
handler.handle(Future.failedFuture(err));
});
}
开发者ID:georocket,项目名称:georocket,代码行数:37,代码来源:FileStore.java
示例6: PropReadFileStream
import io.vertx.core.file.FileProps; //导入依赖的package包/类
private PropReadFileStream(FileProps props, AsyncFile file, String path) {
this.props = props;
this.file = file;
this.path = path;
}
开发者ID:gentics,项目名称:mesh,代码行数:6,代码来源:PropReadFileStream.java
示例7: complete
import io.vertx.core.file.FileProps; //导入依赖的package包/类
void complete(Vertx vertx, String currentPath, String _prefix, Handler<AsyncResult<Map<String, Boolean>>> handler) {
vertx.executeBlocking(fut -> {
FileSystem fs = vertx.fileSystem();
Path base = (currentPath != null ? new File(currentPath).toPath() : rootDir);
int index = _prefix.lastIndexOf('/');
String prefix;
if (index == 0) {
handler.handle(Future.failedFuture("todo"));
return;
} else if (index > 0) {
base = base.resolve(_prefix.substring(0, index));
prefix = _prefix.substring(index + 1);
} else {
prefix = _prefix;
}
LinkedHashMap<String, Boolean> matches = new LinkedHashMap<>();
for (String path : fs.readDirBlocking(base.toAbsolutePath().normalize().toString())) {
String name = path.substring(path.lastIndexOf('/') + 1);
if (name.startsWith(prefix)) {
FileProps props = fs.propsBlocking(path);
matches.put(name.substring(prefix.length()) + (props.isDirectory() ? "/" : ""), props.isRegularFile());
}
}
if (matches.size() > 1) {
String common = Completion.findLongestCommonPrefix(matches.keySet());
if (common.length() > 0) {
matches.clear();
matches.put(common, false);
} else {
LinkedHashMap<String, Boolean> tmp = new LinkedHashMap<>();
matches.forEach((suffix, terminal) -> {
tmp.put(prefix + suffix, terminal);
});
matches = tmp;
}
}
fut.complete(matches);
}, handler);
}
开发者ID:vert-x3,项目名称:vertx-shell,代码行数:47,代码来源:FsHelper.java
示例8: sendStatic
import io.vertx.core.file.FileProps; //导入依赖的package包/类
private void sendStatic(RoutingContext context, String path) {
String file = null;
if (!includeHidden) {
file = getFile(path, context);
int idx = file.lastIndexOf('/');
String name = file.substring(idx + 1);
if (name.length() > 0 && name.charAt(0) == '.') {
// skip
context.next();
return;
}
}
// Look in cache
CacheEntry entry;
if (cachingEnabled) {
entry = propsCache().get(path);
if (entry != null) {
HttpServerRequest request = context.request();
if ((filesReadOnly || !entry.isOutOfDate()) && entry.shouldUseCached(request)) {
context.response().setStatusCode(NOT_MODIFIED.code()).end();
return;
}
}
}
if (file == null) {
file = getFile(path, context);
}
final String sfile = file;
// verify if the file exists
isFileExisting(context, sfile, exists -> {
if (exists.failed()) {
context.fail(exists.cause());
return;
}
// file does not exist, continue...
if (!exists.result()) {
context.next();
return;
}
// Need to read the props from the filesystem
getFileProps(context, sfile, res -> {
if (res.succeeded()) {
FileProps fprops = res.result();
if (fprops == null) {
// File does not exist
context.next();
} else if (fprops.isDirectory()) {
sendDirectory(context, path, sfile);
} else {
propsCache().put(path, new CacheEntry(fprops, System.currentTimeMillis()));
sendFile(context, sfile, fprops);
}
} else {
context.fail(res.cause());
}
});
});
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:67,代码来源:StaticHandlerImpl.java
示例9: CacheEntry
import io.vertx.core.file.FileProps; //导入依赖的package包/类
private CacheEntry(FileProps props, long createDate) {
this.props = props;
this.createDate = createDate;
}
开发者ID:vert-x3,项目名称:vertx-web,代码行数:5,代码来源:StaticHandlerImpl.java
示例10: getProps
import io.vertx.core.file.FileProps; //导入依赖的package包/类
/**
* Gets the filesystem props
*
* @return
*/
public FileProps getProps() {
return props;
}
开发者ID:gentics,项目名称:mesh,代码行数:9,代码来源:PropReadFileStream.java
注:本文中的io.vertx.core.file.FileProps类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论