anchor = null;
    public static SVNWCAccess create(File file) throws SVNException {        File parentFile = file.getParentFile();        String name = file.getName();        try {            if (file.exists()) {                name = file.getCanonicalFile().getName();            }        } catch (IOException e) {        }        if (parentFile != null && (!parentFile.exists() || !parentFile.isDirectory())) {            // parent doesn't exist or not a directory            SVNErrorManager.error(1, null);        }        SVNDirectory anchor = parentFile != null ? new SVNDirectory(parentFile) : null;        SVNDirectory target = file.isDirectory() ? new SVNDirectory(file) : null;                if (anchor == null || !anchor.isVersioned()) {            // parent is not versioned, do not use it.            anchor = null;        }        if (target == null || !target.isVersioned()) {            // target is missing, target is file or not versioned dir.            // do not use it.            target = null;        }        if (target != null && anchor != null) {            // both are versioned dirs,             // check whether target is switched.            SVNEntry targetInAnchor = anchor.getEntries().getEntry(name);                        SVNDirectory anchorCopy = anchor;            try {                if (targetInAnchor == null) {                    // target is disjoint, do not use anchor.                    anchor = null;                } else {                        SVNEntry anchorEntry = anchor.getEntries().getEntry("");                        SVNEntry targetEntry = target.getEntries().getEntry("");                        String anchorURL = anchorEntry.getURL();                        String targetURL = targetEntry.getURL();                        if (anchorURL != null && targetURL != null) {                            String urlName = PathUtil.encode(targetInAnchor.getName());                            String expectedURL = PathUtil.append(anchorURL, urlName);                            if (!expectedURL.equals(targetURL) ||                                     !anchorURL.equals(PathUtil.removeTail(targetURL))) {                                // switched, do not use anchor.                                anchor = null;                                                    } else if (targetInAnchor.isDirectory()){                                // not switched, target is valid dir, just use it.                                anchor = null;                                   }                        }                }             } finally {                // close entries.                if (anchor == null) {                    anchorCopy.getEntries().close();                    anchorCopy.dispose();                    anchorCopy = null;                }                target.dispose();            }        } else if (target == null && anchor == null) {            // both are not versioned :(            SVNErrorManager.error(1, null);        }        return new SVNWCAccess(                anchor != null ? anchor : target,                 target != null ? target : anchor,                 anchor != null ? name : "");    }