[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jedit-cvs
Subject:    [ jEdit-commits ] SF.net SVN: jedit:[24683] jEdit/trunk
From:       ezust () users ! sourceforge ! net
Date:       2017-05-31 5:47:51
Message-ID: 1496209671.283772.27576 () sfp-scm-2 ! v30 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Revision: 24683
          http://sourceforge.net/p/jedit/svn/24683
Author:   ezust
Date:     2017-05-31 05:47:50 +0000 (Wed, 31 May 2017)
Log Message:
-----------
Refactoring autosave and backup miscutilities methods. 

Modified Paths:
--------------
    jEdit/trunk/README.SRC.txt
    jEdit/trunk/org/gjt/sp/jedit/MiscUtilities.java

Modified: jEdit/trunk/README.SRC.txt
===================================================================
--- jEdit/trunk/README.SRC.txt	2017-05-31 04:44:53 UTC (rev 24682)
+++ jEdit/trunk/README.SRC.txt	2017-05-31 05:47:50 UTC (rev 24683)
@@ -1,5 +1,4 @@
 SOURCE CODE NOTES
-asdf
 
 This file only contains information about compiling from source.
 Scroll to the bottom if you are trying to use an IDE like Eclipse.

Modified: jEdit/trunk/org/gjt/sp/jedit/MiscUtilities.java
===================================================================
--- jEdit/trunk/org/gjt/sp/jedit/MiscUtilities.java	2017-05-31 04:44:53 UTC (rev \
                24682)
+++ jEdit/trunk/org/gjt/sp/jedit/MiscUtilities.java	2017-05-31 05:47:50 UTC (rev \
24683) @@ -675,25 +675,12 @@
 	 * the current directory is used, but only for local files.
 	 * The directory is created if does not exist.
 	 * @param path VFS path to the Buffer
-	 * @return Autosave directory. 
+	 * @return Autosave directory, or null if no backup directory is specified and it \
                is a non-local file.
 	 * @since 5.0pre1
 	 */
 	public static File prepareAutosaveDirectory(String path)
 	{
-		// By default, use the same directory as the buffer
-		File f = new File(path);
-		if (!f.isDirectory()) f = f.getParentFile();
-		
-		// unless the backup, autosave directory is specified:
-		String autosaveDir = jEdit.getProperty("backup.directory");
-		if (autosaveDir != null && !autosaveDir.isEmpty()) {
-			path = MiscUtilities.concatPath(autosaveDir, f.getAbsolutePath());
-			File asDir = new File(path);
-			if (!asDir.exists())
-				asDir.mkdirs();
-			f = asDir;
-		}		
-		return f;
+		return prepareBackupDirectory(path);
 	}// }}}
 
 	//{{{ prepareBackupDirectory method
@@ -702,8 +689,8 @@
 	 * jedit property is used to determine the directory.
 	 * If there is no dedicated backup directory specified by props,
 	 * then the current directory is used, but only for local files.
-	 * The directory is created if not exists.
-	 * @param path path to the base dir
+	 * The directory is created if it does not exist. 
+	 * @param path path to the buffer
 	 * @return Backup directory. <code>null</code> is returned for
 	 * non-local files if no backup directory is specified in properties.
 	 * @since 5.0pre1
@@ -711,42 +698,35 @@
 	public static File prepareBackupDirectory(String path)
 	{
 		String backupDirectory = jEdit.getProperty("backup.directory");
-		File dir;
 		boolean isLocal = VFSManager.getVFSForPath(path) instanceof FileVFS;
 		File file;
-		if (isLocal)
+		if (isLocal) {
 			file = new File(path);
-		else
+			
+		}
+		else {
 			file = new File(replaceNonPathChars(path, "_"));
-
-		// Check for backup.directory, and create that
-		// directory if it doesn't exist
+		}
+		if (!file.isDirectory()) file=file.getParentFile();
+		// Check for backup.directory
 		if(backupDirectory == null || backupDirectory.length() == 0)
 		{
 			if (!isLocal)
 				return null;
-			else {
-				backupDirectory = file.getParent();
-				dir = new File(backupDirectory);
-			}
+			else 				
+				return file;			
 		}
 		else
 		{
-			backupDirectory = MiscUtilities.constructPath(
-				System.getProperty("user.home"), backupDirectory);
-
 			// Perhaps here we would want to guard with
 			// a property for parallel backups or not.
 			backupDirectory = MiscUtilities.concatPath(
-				backupDirectory,file.getParent());
-
-			dir = new File(backupDirectory);
-
+				backupDirectory, file.getAbsolutePath());
+			File dir = new File(backupDirectory);
 			if (!dir.exists())
 				dir.mkdirs();
+			return dir;
 		}
-
-		return dir;
 	} //}}}
 
 	//{{{ prepareBackupFile methods

This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
jEdit-CVS mailing list
jEdit-CVS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jedit-cvs


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic