Package io.apigee.trireme.core.internal

Examples of io.apigee.trireme.core.internal.NodeOSException


            try {
                Files.copy(oldFile, newFile, StandardCopyOption.REPLACE_EXISTING);

            } catch (IOException ioe) {
                throw new NodeOSException(getErrorCode(ioe), ioe, oldPath);
            }
        }
View Full Code Here


                    }
                } else {
                    handle.file.truncate(len);
                }
            } catch (IOException e) {
                throw new NodeOSException(getErrorCode(e), e);
            }
        }
View Full Code Here

            if (log.isDebugEnabled()) {
                log.debug("rmdir({})", path);
            }
            Path p = translatePath(path);
            if (!Files.isDirectory(p)) {
                throw new NodeOSException(Constants.ENOTDIR, path);
            }

            try {
                Files.delete(p);
            } catch (IOException ioe) {
                throw new NodeOSException(getErrorCode(ioe), ioe, path);
            }
        }
View Full Code Here

            try {
                Files.delete(p);

            } catch (DirectoryNotEmptyException dne) {
                // Special case because unlinking a directory should be a different error.
                throw new NodeOSException(Constants.EPERM, dne, path);
            } catch (IOException ioe) {
                throw new NodeOSException(getErrorCode(ioe), ioe, path);
            }
        }
View Full Code Here

                    Files.createDirectory(p);
                    setModeNoPosix(p, mode);
                }

            } catch (IOException ioe) {
                throw new NodeOSException(getErrorCode(ioe), ioe, path);
            }
        }
View Full Code Here

            throws NodeOSException
        {
            Path sp = translatePath(dn);
            Context cx = Context.enter();
            if (!Files.isDirectory(sp)) {
                throw new NodeOSException(Constants.ENOTDIR, sp.toString());
            }
            try {
                final ArrayList<String> paths = new ArrayList<String>();
                Set<FileVisitOption> options = Collections.emptySet();
                Files.walkFileTree(sp, options, 1,
                                   new SimpleFileVisitor<Path>() {
                                       @Override
                                       public FileVisitResult visitFile(Path child, BasicFileAttributes attrs)
                                       {
                                           if (log.isTraceEnabled()) {
                                               log.trace("  " + child.getFileName());
                                           }
                                           paths.add(child.getFileName().toString());
                                           return FileVisitResult.CONTINUE;
                                       }
                                   });


                Object[] objs = new Object[paths.size()];
                paths.toArray(objs);
                Scriptable fileList = cx.newArray(this, objs);
                if (log.isDebugEnabled()) {
                    log.debug("readdir({}) = {}", dn, objs.length);
                }
                return new Object[] { Context.getUndefinedValue(), fileList };

            } catch (IOException ioe) {
                throw new NodeOSException(getErrorCode(ioe), ioe, dn);
            } finally {
                Context.exit();
            }
        }
View Full Code Here

                   
                    s = (StatsImpl)cx.newObject(this, StatsImpl.CLASS_NAME);
                    s.setAttributes(cx, p, attrs);

                } catch (IOException ioe) {
                    throw new NodeOSException(getErrorCode(ioe), ioe, p.toString());
                } catch (Throwable t) {
                    log.error("Error on stat: {}", t);
                    throw new NodeOSException("Error on Stat", t);
                }
               
                if (log.isTraceEnabled()) {
                    log.trace("stat {} = {}", p, s);
                }
View Full Code Here

                // The timestamp seems to come from JavaScript as a decimal value of seconds
                FileTime newATime = FileTime.fromMillis((long)(atime * 1000.0));
                FileTime newMTime = FileTime.fromMillis((long)(mtime * 1000.0));
                attrView.setTimes(newMTime, newATime, attrs.creationTime());
            } catch (IOException ioe) {
                throw new NodeOSException(getErrorCode(ioe), ioe, path.toString());
            }
            return new Object[] { Context.getUndefinedValue(), Context.getUndefinedValue() };
        }
View Full Code Here

                } else {
                    Files.setAttribute(path, "posix:permissions", perms);
                }
                return new Object[] { Context.getUndefinedValue(), Context.getUndefinedValue() };
            } catch (IOException ioe) {
                throw new NodeOSException(getErrorCode(ioe), ioe, path.toString());
            }
        }
View Full Code Here

                } else {
                    Files.setOwner(path, user);
                }
                return new Object[] { Context.getUndefinedValue(), Context.getUndefinedValue() };
            } catch (IOException ioe) {
                throw new NodeOSException(getErrorCode(ioe), ioe, path.toString());
            }
        }
View Full Code Here

TOP

Related Classes of io.apigee.trireme.core.internal.NodeOSException

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.