private static void markLogProcessed(File logFile) throws SVNException { SVNFileUtil.setReadonly(logFile, false); OutputStream os = null; try { os = SVNFileUtil.openFileForWriting(logFile); } finally { if (os != null) { SVNFileUtil.closeFile(os); } } }
public void close() throws IOException { os.close(); File baseFile = getBaseFile(myName, false); try { SVNFileUtil.rename(myTmpFile, baseFile); } catch (SVNException e) { throw new IOException(e.getMessage()); } SVNFileUtil.setReadonly(baseFile, true); } };
public void close() throws IOException { os.close(); File baseFile = getBaseFile(myName, false); try { SVNFileUtil.rename(myTmpFile, baseFile); } catch (SVNException e) { throw new IOException(e.getMessage()); } SVNFileUtil.setReadonly(baseFile, true); } };
private static void markLogProcessed(File logFile) throws SVNException { SVNFileUtil.setReadonly(logFile, false); OutputStream os = null; try { os = SVNFileUtil.openFileForWriting(logFile); } finally { if (os != null) { SVNFileUtil.closeFile(os); } } }
public void close() throws IOException { os.close(); File baseFile = getBaseFile(myName, false); try { SVNFileUtil.rename(myTmpFile, baseFile); } catch (SVNException e) { throw new IOException(e.getMessage()); } SVNFileUtil.setReadonly(baseFile, true); } };
public void close() throws IOException { os.close(); File baseFile = getBaseFile(myName, false); try { SVNFileUtil.rename(myTmpFile, baseFile); } catch (SVNException e) { throw new IOException(e.getMessage()); } SVNFileUtil.setReadonly(baseFile, true); } };
private static void markLogProcessed(File logFile) throws SVNException { SVNFileUtil.setReadonly(logFile, false); OutputStream os = null; try { os = SVNFileUtil.openFileForWriting(logFile); } finally { if (os != null) { SVNFileUtil.closeFile(os); } } }
public static OutputStream openFileForWriting(File file, boolean append) throws SVNException { if (file == null) { return null; } if (file.getParentFile() != null && !file.getParentFile().exists()) { file.getParentFile().mkdirs(); } if (isOpenVMS && !append && file.isFile()) { deleteFile(file); } else if (file.isFile() && !file.canWrite()) { // force writable. setReadonly(file, false); } try { return new BufferedOutputStream(createFileOutputStream(file, append)); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Cannot write to ''{0}'': {1}", new Object[] { file, e.getMessage() }); SVNErrorManager.error(err, e, Level.FINE, SVNLogType.DEFAULT); } return null; }
public static OutputStream openFileForWriting(File file, boolean append) throws SVNException { if (file == null) { return null; } if (file.getParentFile() != null && !file.getParentFile().exists()) { file.getParentFile().mkdirs(); } if (isOpenVMS && !append && file.isFile()) { deleteFile(file); } else if (file.isFile() && !file.canWrite()) { // force writable. setReadonly(file, false); } try { return new BufferedOutputStream(createFileOutputStream(file, append)); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Cannot write to ''{0}'': {1}", new Object[]{file, e.getMessage()}); SVNErrorManager.error(err, e, Level.FINE, SVNLogType.DEFAULT); } return null; }
public static OutputStream openFileForWriting(File file, boolean append) throws SVNException { if (file == null) { return null; } if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } if (file.isFile() && !file.canWrite()) { // force writable. if (append) { setReadonly(file, false); } else { deleteFile(file); } } try { return new BufferedOutputStream(new FileOutputStream(file, append)); } catch (FileNotFoundException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Cannot write to ''{0}'': {1}", new Object[] {file, e.getLocalizedMessage()}); SVNErrorManager.error(err, e); } return null; }
public static boolean moveFile(File src, File dst) { if (src == null || dst == null) { return false; } ISVNKernel32Library library = JNALibraryLoader.getKernelLibrary(); if (library == null) { // use ugly way. return false; } if (dst.isFile() && !dst.canWrite()) { SVNFileUtil.setReadonly(dst, false); SVNFileUtil.setReadonly(src, true); } synchronized (library) { try { int rc = library.MoveFileExW(new WString(src.getAbsoluteFile().getAbsolutePath()), new WString(dst.getAbsoluteFile().getAbsolutePath()), new NativeLong(3)); return rc != 0; } catch (Throwable th) { } } return false; }
public static void setProperties(SVNProperties namesToValues, File target, File tmpFile, String terminator) throws SVNException { OutputStream dst = null; try { if (tmpFile != null) { tmpFile.getParentFile().mkdirs(); } else { target.getParentFile().mkdirs(); } dst = SVNFileUtil.openFileForWriting(tmpFile != null ? tmpFile : target); setProperties(namesToValues, dst, terminator); } finally { SVNFileUtil.closeFile(dst); } if (tmpFile != null && target != null) { target.getParentFile().mkdirs(); SVNFileUtil.rename(tmpFile, target); } if (target != null) { SVNFileUtil.setReadonly(target, true); } }
public static void setProperties(SVNProperties namesToValues, File target, File tmpFile, String terminator) throws SVNException { OutputStream dst = null; try { if (tmpFile != null) { tmpFile.getParentFile().mkdirs(); } else { target.getParentFile().mkdirs(); } dst = SVNFileUtil.openFileForWriting(tmpFile != null ? tmpFile : target); setProperties(namesToValues, dst, terminator); } finally { SVNFileUtil.closeFile(dst); } if (tmpFile != null && target != null) { target.getParentFile().mkdirs(); SVNFileUtil.rename(tmpFile, target); } if (target != null) { SVNFileUtil.setReadonly(target, true); } }
public static void setProperties(SVNProperties namesToValues, File target, File tmpFile, String terminator) throws SVNException { OutputStream dst = null; try { if (tmpFile != null) { tmpFile.getParentFile().mkdirs(); } else { target.getParentFile().mkdirs(); } dst = SVNFileUtil.openFileForWriting(tmpFile != null ? tmpFile : target); setProperties(namesToValues, dst, terminator); } finally { SVNFileUtil.closeFile(dst); } if (tmpFile != null && target != null) { target.getParentFile().mkdirs(); SVNFileUtil.rename(tmpFile, target); } if (target != null) { SVNFileUtil.setReadonly(target, true); } }
public void syncFileFlags(File localAbspath) throws SVNException { SVNFileUtil.setReadonly(localAbspath, false); SVNFileUtil.setExecutable(localAbspath, false); maybeSetReadOnly(localAbspath); maybeSetExecutable(localAbspath); }
public static void writeVersionFile(File file, int version) throws SVNException { if (version < 0) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.INCORRECT_PARAMS, "Version {0} is not non-negative", new Integer(version)); SVNErrorManager.error(err, Level.FINE, SVNLogType.WC); } String contents = version + "\n"; File tmpFile = SVNFileUtil.createUniqueFile(SVNFileUtil.getFileDir(file), SVNFileUtil.getFileName(file), ".tmp", false); OutputStream os = null; try { os = SVNFileUtil.openFileForWriting(tmpFile); os.write(contents.getBytes("US-ASCII")); } catch (IOException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e.getMessage()); SVNErrorManager.error(err, e, Level.FINE, SVNLogType.DEFAULT); } finally { SVNFileUtil.closeFile(os); } if (isWindows) { setReadonly(file, false); } SVNFileUtil.rename(tmpFile, file); setReadonly(file, true); }
private void storeServerCertificate(String realm, String data, int failures) throws SVNException { myAuthDirectory.mkdirs(); File file = new File(myAuthDirectory, SVNFileUtil.computeChecksum(realm)); SVNProperties props = new SVNProperties(file, ""); props.delete(); try { props.setPropertyValue("ascii_cert", data); props.setPropertyValue("svn:realmstring", realm); props.setPropertyValue("failures", Integer.toString(failures)); SVNFileUtil.setReadonly(props.getFile(), false); } catch (SVNException e) { props.delete(); } }
public static void setProperties(Map namesToValues, File target, File tmpFile, String terminator) throws SVNException { OutputStream dst = null; try { //tmpFile = SVNFileUtil.createUniqueFile(target.getParentFile(), target.getName(), ".tmp"); dst = SVNFileUtil.openFileForWriting(tmpFile); setProperties(namesToValues, dst, terminator); } finally { SVNFileUtil.closeFile(dst); } if (tmpFile != null) { SVNFileUtil.rename(tmpFile, target); SVNFileUtil.setReadonly(target, true); } }
public void handleUnlock(String path, SVNLock lock, SVNErrorMessage error) throws SVNException { SVNURL fullURL = rootURL.appendPath(path, false); LockInfo lockInfo = (LockInfo) entriesMap.get(fullURL); SVNEventAction action = null; if (error == null || (error != null && error.getErrorCode() != SVNErrorCode.FS_LOCK_OWNER_MISMATCH)) { getWcContext().getDb().removeLock(lockInfo.getFile()); if (getWcContext().getProperty(lockInfo.getFile(), SVNProperty.NEEDS_LOCK) != null) { SVNFileUtil.setReadonly(lockInfo.getFile(), true); } action = SVNEventAction.UNLOCKED; } if (error != null) { action = SVNEventAction.UNLOCK_FAILED; } if (action != null) { handleEvent(SVNEventFactory.createLockEvent(lockInfo.getFile(), action, lock, error), ISVNEventHandler.UNKNOWN); } } });
public void handleLock(String path, SVNLock lock, SVNErrorMessage error) throws SVNException { SVNURL fullURL = rootURL.appendPath(path, false); LockInfo lockInfo = (LockInfo) entriesMap.get(fullURL); if (error == null) { SVNWCDbLock dbLock = new SVNWCDbLock(); dbLock.token = lock.getID(); dbLock.owner = lock.getOwner(); dbLock.comment = lock.getComment(); dbLock.date = SVNDate.fromDate(lock.getCreationDate()); getWcContext().getDb().addLock(lockInfo.getFile(), dbLock); if (getWcContext().getProperty(lockInfo.getFile(), SVNProperty.NEEDS_LOCK) != null) { SVNFileUtil.setReadonly(lockInfo.getFile(), false); } handleEvent(SVNEventFactory.createLockEvent(lockInfo.getFile(), SVNEventAction.LOCKED, lock, null), ISVNEventHandler.UNKNOWN); } else { handleEvent(SVNEventFactory.createLockEvent(lockInfo.getFile(), SVNEventAction.LOCK_FAILED, lock, error), ISVNEventHandler.UNKNOWN); } }