////////////////////////////////////////////////////////////////////////////////
// Private - START
//
// logFilesize outputs a friendly filesize for the given filepath
763337
func logFilesize(message string, filePath string, logger *logrus.Logger) {
	// Binary size
	stat, err := os.Stat(filePath)
	if err == nil {
		logger.WithFields(logrus.Fields{
			"Size": humanize.Bytes(uint64(stat.Size())),
		}).Info(message)
	}
}
705314
def file_size(path, rel = nil)
      return 0 if path.nil?
      path = path =~ /\// ? path : File.join('episodes', path)
      path = rel + path if rel
      File.size(path)
    end
1220917
def dirsize_get(l_filesWithoutPath, **kwargs):
        

        str_path    = ""
        for k,v in kwargs.items():
            if k == 'path': str_path = v

        d_ret   = {}
        l_size  = []
        size    = 0
        for f in l_filesWithoutPath:
            str_f   = '%s/%s' % (str_path, f)
            if not os.path.islink(str_f):
                try:
                    size += os.path.getsize(str_f)
                except:
                    pass
        str_size    = pftree.sizeof_fmt(size)

        return {
            'status':           True,
            'diskUsage_raw':    size,
            'diskUsage_human':  str_size
        }
1155137
func fileSize(filename string) (size int64, ok bool) {
	info, err := os.Stat(filename)
	ok = err == nil
	if ok {
		size = info.Size()
	}
	return
}
526738
long getPreferredBlockSize(String filename) throws IOException {
    byte[][] components = INodeDirectory.getPathComponents(filename);
    readLock();
    try {
      INode fileNode = rootDir.getNode(components);
      if (fileNode == null) {
        throw new IOException("Unknown file: " + filename);
      }
      if (fileNode.isDirectory()) {
        throw new IOException("Getting block size of a directory: " +
                              filename);
      }
      return ((INodeFile)fileNode).getPreferredBlockSize();
    } finally {
      readUnlock();
    }
  }
1093947
@Override
    public void enlargeFile(long toEnlarge) throws IOException {
        size += (long) Math.ceil((double) toEnlarge / incrementSize) * incrementSize;
        logger.debug("Enlarge filesize of {} to {}", osFile, size);
        contentEnd = size;
        accessFile.setLength(size);

        // TODO check buffer size
        // if there are more chunks than the index can contain
        if ((size - contentStart) / chunkSize > indexSize) {
            logger.error("File-Enlargement not possible. The index becomes too large.");
            throw new IOException("File-Enlargement not possible. The index becomes too large.");
        }
        calcIndexInformations();
    }
67679
def show_big_file(dir_path, threshold):
        
        fc = FileCollection.from_path_by_size(dir_path, min_size=threshold)
        fc.sort_by("size_on_disk")
        
        lines = list()
        lines.append("Results:")
        for winfile in fc.iterfiles():
            lines.append("  %s - %s" % 
                         (string_SizeInBytes(winfile.size_on_disk), winfile))
        lines.append("Above are files' size greater than %s." % 
              string_SizeInBytes(threshold))
        text = "\n".join(lines)
        print(text)
        with open("__show_big_file__.log", "wb") as f:
            f.write(text.encode("utf-8"))
412064
public void downloadFile(int fileId, java.io.File target, FileSize size)
			throws IOException {
		WebResource builder = getResourceFactory()
				.getFileResource("/" + fileId);
		if (size != null) {
			builder = builder.path("/" + size.name().toLowerCase());
		}
		byte[] data = builder.get(byte[].class);
		FileUtils.writeByteArrayToFile(target, data);
	}
823027
function verifySize(correctSize, filepath) {
    return calculateSize(filepath).then(size => {
        if (size !== correctSize) {
            throw new Error(`Incorrect file size: expected ${correctSize}, got ${size}`);
        }
        return true;
    });
}
136694
function calculateSize(filepath) {
    return new Promise((fulfill, reject) => {
        fs.stat(filepath, (err, stats) => {
            if (err) return reject(err);
            fulfill(stats.size);
        });
    });
}
1106253
def get_file_size(filename):
    
    if os.path.isfile(filename):
        return convert_size(os.path.getsize(filename))
    return None
1283751
function generateSizes(entry, inputDirectory, outputDirectory) {
  const imageFileName = path.join(inputDirectory, entry.basename);
  return pify(fs.readFile)(imageFileName).then(imageBuffer => {
    const sharpFile = sharp(imageBuffer);
    return Promise.all(
      entry.sizes.map(size => {
        const sizeSuffix = createSizeSuffix(size.width, size.height);
        const ext = path.extname(entry.basename);
        const extlessBasename = path.basename(entry.basename, ext);
        const outputFilename = path.join(
          outputDirectory,
          `${extlessBasename}-${sizeSuffix}${ext}`
        );
        const transform = sharpFile.resize(size.width, size.height);
        if (size.crop !== undefined) {
          transform.crop(getCropper(size.crop));
        }
        return transform.toFile(outputFilename).then(() => outputFilename);
      })
    );
  });
}
906642
static long calculateDirSizeAndSave(final File dir) throws IOException {
    final Path path = Paths.get(dir.getPath(), FlowPreparer.PROJECT_DIR_SIZE_FILE_NAME);
    if (!Files.exists(path)) {
      final long sizeInByte = FileUtils.sizeOfDirectory(dir);
      FileIOUtils.dumpNumberToFile(path, sizeInByte);
      return sizeInByte;
    } else {
      return FileIOUtils.readNumberFromFile(path);
    }
  }
1197441
def _get_file_size(path, get_retriever):
    
    integration, config = get_retriever.integration_and_config(path)
    if integration:
        return integration.file_size(path, config)
    elif os.path.exists(path):
        return os.path.getsize(path) / (1024.0 * 1024.0)
602627
function calcRelPath(filePath, linkPath) {
    filePath = filePath.replace(`\\`, `/`);
    linkPath = linkPath.replace(`\\`, `/`);
    let RelPath = '',
        linkPathList = linkPath.split('/'),
        filePathList = filePath.split('/'),
        idx = 0;
    console.log(`File Path : ${filePath}, link path : ${linkPath}`);
    for (let i = 1; i < filePathList.length - 1; i++) {
        idx = i;
        if (filePathList[i] === linkPathList[i])
            break;
        RelPath += '../';
    }

    if (RelPath.length === 0) {
        RelPath += './';
        idx += 1;
    }

    if (idx === 0) idx += 1;

    for (let i = idx; i < linkPathList.length - 1; i++) {
        RelPath += linkPathList[i] + '/';
    }

    RelPath += linkPathList[linkPathList.length - 1];
    console.log(`RelPath : ${RelPath}`);
    return RelPath;
}
923893
@Override
    public long getContentSize(Context ctx) throws StreamIOException {
        try {
            // For new or modified datastreams, the new bytestream hasn't yet been
            // committed. However, we need to access it in order to compute
            // the datastream checksum
            if (DSLocation.startsWith(UPLOADED_SCHEME)) {
                // TODO: refactor to use proper temp file management - FCREPO-718
                // for now, just get the file directly (see also DefaultManagement.getTempStream(...))
                String internalId = DSLocation.substring(UPLOADED_SCHEME.length());
                File uploadedFile = new File(getTempUploadDir(), internalId);
                // check it has not been automatically purged (see DefaultManagement.purgeUploadedFiles())
                if (uploadedFile.exists()) {
                    return uploadedFile.length();
                } else {
                    throw new StreamIOException("Uploaded file " + DSLocation + " no longer exists.");
                }

            } else if (DSLocation.startsWith(TEMP_SCHEME)) {
                // TODO: refactor to use proper temp file management - FCREPO-718
                String fileName = DSLocation.substring(TEMP_SCHEME.length());
                File tempFile = new File(fileName);
                // check it has not been removed elsewhere (should not happen)
                if (tempFile.exists()) {
                    return tempFile.length();
                } else {
                    throw new StreamIOException("Temp file " + DSLocation + " no longer exists.");
                }
            } else if (Datastream.DS_LOCATION_TYPE_INTERNAL.equals(DSLocationType)) {
                ILowlevelStorage llstore = getLLStore();
                if (s_llsizable) {
                    return ((ISizable)llstore).getDatastreamSize(DSLocation);
                } else {
                    return 0;
                }
            } else if (Datastream.DS_LOCATION_TYPE_URL.equals(DSLocationType)) {
                // Managed content can have URL dsLocation on ingest
                ValidationUtility.validateURL(DSLocation, this.DSControlGrp);
                // If validation has succeeded, assume an external resource.
                // Fetch it, store it locally, update DSLocation
                if (ctx == null) {
                    ctx = ReadOnlyContext.getContext(null, null, "", false);
                    // changed from below, which sets noOp to true, seems to cause an AuthZ permitted exception
                    // in PolicyEnforcementPoint.enforce(...)
                    // ctx = ReadOnlyContext.EMPTY;
                }
               ContentManagerParams params = new ContentManagerParams(DSLocation);
                params.setContext(ctx);
                MIMETypedStream stream = getExternalContentManager()
                        .getExternalContent(params);

                // TODO: refactor temp file management - see FCREPO-718; for now create temp file and write to it
                // note - don't use temp upload directory, use (container's) temp dir (upload dir is for uploads)
                File tempFile = File.createTempFile("managedcontentupdate", null);
                OutputStream os = new FileOutputStream(tempFile);
                StreamUtility.pipeStream(stream.getStream(), os, 32768);
                DSLocation = TEMP_SCHEME + tempFile.getAbsolutePath();
                return tempFile.length();
            }
        } catch (Throwable th) {
            throw new StreamIOException("[DatastreamManagedContent] returned "
                    + " the error: \"" + th.getClass().getName()
                    + "\". Reason: " + th.getMessage(), th);
        }
        throw new StreamIOException("[DatastreamManagedContent] could not resolve dsLocation " + DSLocation + " dsLocationType " + DSLocationType);
    }
473871
def _reduce_file_size_if_necessary(fileName, maxSize):
    
    fileSize = os.path.getsize(fileName)

    if maxSize is None:
        logging.debug("Size of logfile '%s' is %s bytes, size limit disabled.", fileName, fileSize)
        return # disabled, nothing to do

    if fileSize < (maxSize + 500):
        logging.debug("Size of logfile '%s' is %s bytes, nothing to do.", fileName, fileSize)
        return

    logging.warning("Logfile '%s' is too big (size %s bytes). Removing lines.", fileName, fileSize)
    util.shrink_text_file(fileName, maxSize, _LOG_SHRINK_MARKER)