/**
* Setter for file path.
*
* @param path New path
*/
public void setPath(String path) {
log.debug("Set path: {}", path);
Resource rootFile = resources.getResource(path);
try {
// check for existence
if (!rootFile.exists()) {
log.debug("Persistence directory does not exist");
if (rootFile instanceof ServletContextResource) {
ServletContextResource servletResource = (ServletContextResource) rootFile;
String contextPath = servletResource.getServletContext().getContextPath();
log.debug("Persistence context path: {}", contextPath);
if ("/".equals(contextPath)) {
contextPath = "/root";
}
rootDir = String.format("%s/webapps%s/persistence", System.getProperty("red5.root"), contextPath);
log.debug("Persistence directory path: {}", rootDir);
File persistDir = new File(rootDir);
if (!persistDir.mkdir()) {
log.warn("Persistence directory creation failed");
} else {
log.debug("Persistence directory access - read: {} write: {}", persistDir.canRead(), persistDir.canWrite());
}
persistDir = null;
}
} else {
rootDir = rootFile.getFile().getAbsolutePath();
}
log.debug("Root dir: {} path: {}", rootDir, path);
this.path = path;
} catch (IOException err) {
log.error("I/O exception thrown when setting file path to {}", path, err);
throw new RuntimeException(err);
}
storeThread = FilePersistenceThread.getInstance();
}
FilePersistence.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:red5-mobileconsole
作者:
评论列表
文章目录