/** * Create a new file entry given the specified FileModeStrategy * * @param f * file * @param fs * file system * @param attributes * of the file * @param fileModeStrategy * the strategy to use when determining the FileMode of a * file; controls gitlinks etc. * * @since 5.0 */ public FileEntry(File f, FS fs, FS.Attributes attributes, FileModeStrategy fileModeStrategy) { this.fs = fs; this.attributes = attributes; f = fs.normalize(f); mode = fileModeStrategy.getMode(f, attributes); }
/** * Create a new file entry given the specified FileModeStrategy * * @param f * file * @param fs * file system * @param fileModeStrategy * the strategy to use when determining the FileMode of a * file; controls gitlinks etc. * * @since 4.3 */ public FileEntry(File f, FS fs, FileModeStrategy fileModeStrategy) { this.fs = fs; f = fs.normalize(f); attributes = fs.getAttributes(f); mode = fileModeStrategy.getMode(f, attributes); }
private static String readContentAsNormalizedString(DirCacheEntry entry, ObjectReader reader) throws MissingObjectException, IOException { ObjectLoader open = reader.open(entry.getObjectId()); byte[] cachedBytes = open.getCachedBytes(); return FS.detect().normalize(RawParseUtils.decode(cachedBytes)); }
/** * Reads the target of a symlink as a string. This default implementation * fully reads the entry's input stream and converts it to a normalized * string. Subclasses may override to provide more specialized * implementations. * * @param entry * to read * @return the entry's content as a normalized string * @throws java.io.IOException * if the entry cannot be read or does not denote a symlink * @since 4.6 */ protected String readSymlinkTarget(Entry entry) throws IOException { if (!entry.getMode().equals(FileMode.SYMLINK)) { throw new java.nio.file.NotLinkException(entry.getName()); } long length = entry.getLength(); byte[] content = new byte[(int) length]; try (InputStream is = entry.openInputStream()) { int bytesRead = IO.readFully(is, content, 0); return FS.detect() .normalize(RawParseUtils.decode(content, 0, bytesRead)); } }
/** * Create a new file entry given the specified FileModeStrategy * * @param f * file * @param fs * file system * @param attributes * of the file * @param fileModeStrategy * the strategy to use when determining the FileMode of a * file; controls gitlinks etc. * * @since 5.0 */ public FileEntry(File f, FS fs, FS.Attributes attributes, FileModeStrategy fileModeStrategy) { this.fs = fs; this.attributes = attributes; f = fs.normalize(f); mode = fileModeStrategy.getMode(f, attributes); }
/** * Create a new file entry given the specified FileModeStrategy * * @param f * file * @param fs * file system * @param fileModeStrategy * the strategy to use when determining the FileMode of a * file; controls gitlinks etc. * * @since 4.3 */ public FileEntry(File f, FS fs, FileModeStrategy fileModeStrategy) { this.fs = fs; f = fs.normalize(f); attributes = fs.getAttributes(f); mode = fileModeStrategy.getMode(f, attributes); }
/** * Create a new file entry given the specified FileModeStrategy * * @param f * file * @param fs * file system * @param fileModeStrategy * the strategy to use when determining the FileMode of a * file; controls gitlinks etc. * * @since 4.3 */ public FileEntry(File f, FS fs, FileModeStrategy fileModeStrategy) { this.fs = fs; f = fs.normalize(f); attributes = fs.getAttributes(f); mode = fileModeStrategy.getMode(f, attributes); }
private static String readContentAsNormalizedString(DirCacheEntry entry, ObjectReader reader) throws MissingObjectException, IOException { ObjectLoader open = reader.open(entry.getObjectId()); byte[] cachedBytes = open.getCachedBytes(); return FS.detect().normalize(RawParseUtils.decode(cachedBytes)); }
private static String readContentAsNormalizedString(Entry entry) throws IOException { long length = entry.getLength(); byte[] content = new byte[(int) length]; InputStream is = entry.openInputStream(); IO.readFully(is, content, 0, (int) length); return FS.detect().normalize(RawParseUtils.decode(content)); }
private static String readContentAsNormalizedString(DirCacheEntry entry, ObjectReader reader) throws MissingObjectException, IOException { ObjectLoader open = reader.open(entry.getObjectId()); byte[] cachedBytes = open.getCachedBytes(); return FS.detect().normalize(RawParseUtils.decode(cachedBytes)); }
/** * Reads the target of a symlink as a string. This default implementation * fully reads the entry's input stream and converts it to a normalized * string. Subclasses may override to provide more specialized * implementations. * * @param entry * to read * @return the entry's content as a normalized string * @throws java.io.IOException * if the entry cannot be read or does not denote a symlink * @since 4.6 */ protected String readSymlinkTarget(Entry entry) throws IOException { if (!entry.getMode().equals(FileMode.SYMLINK)) { throw new java.nio.file.NotLinkException(entry.getName()); } long length = entry.getLength(); byte[] content = new byte[(int) length]; try (InputStream is = entry.openInputStream()) { int bytesRead = IO.readFully(is, content, 0); return FS.detect() .normalize(RawParseUtils.decode(content, 0, bytesRead)); } }