Package org.vertx.java.core.file

Examples of org.vertx.java.core.file.FileSystemException


                });
          } else {
            Files.copy(source, target);
          }
        } catch (IOException e) {
          throw new FileSystemException(e);
        }
        return null;
      }
    };
  }
View Full Code Here


    return new BlockingAction<Void>(vertx, handler) {
      public Void action() {
        try {
          Files.move(source, target);
        } catch (IOException e) {
          throw new FileSystemException(e);
        }
        return null;
      }
    };
  }
View Full Code Here

  private BlockingAction<Void> truncateInternal(String p, final long len, Handler<AsyncResult<Void>> handler) {
    final String path = PathAdjuster.adjust(vertx, p);
    return new BlockingAction<Void>(vertx, handler) {
      public Void action() {
        if (len < 0) {
          throw new FileSystemException("Cannot truncate file to size < 0");
        }
        if (!Files.exists(Paths.get(path))) {
          throw new FileSystemException("Cannot truncate file " + path + ". Does not exist");
        }
        RandomAccessFile raf = null;
        try {
          try {
            raf = new RandomAccessFile(path, "rw");
            raf.getChannel().truncate(len);
          } finally {
            if (raf != null) raf.close();
          }
        } catch (IOException e) {
          throw new FileSystemException(e);
        }
        return null;
      }
    };
  }
View Full Code Here

            });
          } else {
            Files.setPosixFilePermissions(target, permissions);
          }
        } catch (SecurityException e) {
          throw new FileSystemException("Accessed denied for chmod on " + target);
        } catch (IOException e) {
          throw new FileSystemException(e);
        }
        return null;
      }
    };
  }
View Full Code Here

          } else {
            attrs = Files.readAttributes(target, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
          }
          return new DefaultFileProps(attrs);
        } catch (IOException e) {
          throw new FileSystemException(e);
        }
      }
    };
  }
View Full Code Here

            Files.createSymbolicLink(source, target);
          } else {
            Files.createLink(source, target);
          }
        } catch (IOException e) {
          throw new FileSystemException(e);
        }
        return null;
      }
    };
  }
View Full Code Here

    return new BlockingAction<String>(vertx, handler) {
      public String action() {
        try {
          return Files.readSymbolicLink(source).toString();
        } catch (IOException e) {
          throw new FileSystemException(e);
        }
      }
    };
  }
View Full Code Here

            });
          } else {
            Files.delete(source);
          }
        } catch (IOException e) {
          throw new FileSystemException(e);
        }
        return null;
      }
    };
  }
View Full Code Here

            } else {
              Files.createDirectory(source);
            }
          }
        } catch (IOException e) {
          throw new FileSystemException(e);
        }
        return null;
      }
    };
  }
View Full Code Here

    return new BlockingAction<String[]>(vertx, handler) {
      public String[] action() {
        try {
          File file = new File(path);
          if (!file.exists()) {
            throw new FileSystemException("Cannot read directory " + path + ". Does not exist");
          }
          if (!file.isDirectory()) {
            throw new FileSystemException("Cannot read directory " + path + ". It's not a directory");
          } else {
            FilenameFilter fnFilter;
            if (filter != null) {
              fnFilter = new FilenameFilter() {
                public boolean accept(File dir, String name) {
                  return Pattern.matches(filter, name);
                }
              };
            } else {
              fnFilter = null;
            }
            File[] files;
            if (fnFilter == null) {
              files = file.listFiles();
            } else {
              files = file.listFiles(fnFilter);
            }
            String[] ret = new String[files.length];
            int i = 0;
            for (File f : files) {
              ret[i++] = f.getCanonicalPath();
            }
            return ret;
          }
        } catch (IOException e) {
          throw new FileSystemException(e);
        }
      }
    };
  }
View Full Code Here

TOP

Related Classes of org.vertx.java.core.file.FileSystemException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.