Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.netbeans.lib.cvsclient.file;
  
  import  org.netbeans.lib.cvsclient.admin.IAdminReader;
  import  org.netbeans.lib.cvsclient.util.BugLog;
  
  import java.io.File;

Author(s):
Thomas Singer
 
 public final class CvsFileSystem
         implements ICvsFileSystem {
 
 	// Fields =================================================================
 
 	private final IFileSystem localFileSystem;
 	private final IFileSystem adminFileSystem;
 	private final String repository;
 
 	// Setup ==================================================================
 
 	public CvsFileSystem(File rootDirectoryString repository) {
 		this(rootDirectoryrootDirectoryrepository);
 	}
 
 	public CvsFileSystem(File localRootDirectoryFile adminRootDirectoryString repository) {
 		BugLog.getInstance().assertNotNull(localRootDirectory);
 		BugLog.getInstance().assertNotNull(adminRootDirectory);
 		BugLog.getInstance().assertNotNull(repository);
 
 		this. = new FileSystem(localRootDirectory);
 		this. = new FileSystem(adminRootDirectory);
 		this. = FileUtils.ensureTrailingSlash(repository).replace('\\''/');
 	}
 
 	// Implemented ============================================================
 

Parameters:
relativeLocalDirectoryPath ends with a trailing slash (e.g. "./" or "dir/" or "dir1/dir2")
repositoryFilePath ends with a trailing slash, if it is a directory ("e.g. "module/" or "module/file.txt")
 
 	public FileObject getFileObject(String relativeLocalDirectoryPathString repositoryFilePath) {
 		BugLog.getInstance().assertTrue(!relativeLocalDirectoryPath.startsWith("/"), "relativeLocalDirectory '" + relativeLocalDirectoryPath + "' must not start with /");
 		BugLog.getInstance().assertTrue(relativeLocalDirectoryPath.endsWith("/"), "relativeLocalDirectory '" + relativeLocalDirectoryPath + "' must end with /");
 		BugLog.getInstance().assertTrue(!repositoryFilePath.endsWith("/"), "repositoryFilePath '" + repositoryFilePath + "' must not end with /");
 		BugLog.getInstance().assertTrue(repositoryFilePath.indexOf('/') >= 0, "repositoryFileName '" + repositoryFilePath + "' must contain a /");
 
 		if (relativeLocalDirectoryPath.equals("./")) { // NOI18N
 			relativeLocalDirectoryPath = "";
 		}
 
 		final String fileName = getFileNameFromRepositoryPath(repositoryFilePath);
 		return FileObject.createInstance('/' + relativeLocalDirectoryPath + fileName);
 	}
 
 	public DirectoryObject getDirectoryObject(String relativeLocalDirectoryPathString repositoryDirectoryPath) {
 		BugLog.getInstance().assertTrue(!relativeLocalDirectoryPath.startsWith("/"), "relativeLocalDirectoryPath '" + relativeLocalDirectoryPath + "' must not start with /");
 		BugLog.getInstance().assertTrue(relativeLocalDirectoryPath.endsWith("/"), "relativeLocalDirectoryPath '" + relativeLocalDirectoryPath + "' must end with /");
 		BugLog.getInstance().assertTrue(repositoryDirectoryPath.endsWith("/"), "repositoryDirectoryPath '" + repositoryDirectoryPath + "' must end with /");
 
 		if (relativeLocalDirectoryPath.equals("./")) {
 			relativeLocalDirectoryPath = "";
 		}
 
 		return DirectoryObject.createInstance('/' + FileUtils.removeTrailingSlash(relativeLocalDirectoryPath));
 	}
 
 	public IFileSystem getLocalFileSystem() {
 		return ;
 	}
 
 	public IFileSystem getAdminFileSystem() {
 		return ;
 	}
 
 	public String getRelativeRepositoryPath(String repositoryPath) {
           if (repositoryPath.startsWith()) {
             String relativeRepositoryPath = repositoryPath.substring(.length());
             relativeRepositoryPath = FileUtils.removeTrailingSlash(relativeRepositoryPath);
             if (relativeRepositoryPath.length() == 0) {
                     relativeRepositoryPath = ".";
             }
             return relativeRepositoryPath;
           } else {
             return FileUtils.removeTrailingSlash(repositoryPath);
           }
         }
 
 	public String getRepositoryForDirectory(DirectoryObject directoryObject, IAdminReader adminReader) {
 		try {
 			return adminReader.getRepositoryForDirectory(directoryObjectthis);
 		}
 		catch (IOException ex) {
 			return FileUtils.removeTrailingSlash() + directoryObject.getPath();
 		}
 	}
 
 	public FileObject unixFileNameToFileObject(String unixFileName) {
		return FileObject.createInstance('/' + unixFileName);
	}
	// Utils ==================================================================
	private static String getFileNameFromRepositoryPath(String repositoryFilePath) {
		final int lastSlashIndex = repositoryFilePath.lastIndexOf('/');
		return repositoryFilePath.substring(lastSlashIndex + 1);
	}
New to GrepCode? Check out our FAQ X