Does not include the size on the ID template, also strips any file extension if it will not leave the filename empty.
334033
@Override
	protected String getElementIdTemplate() {
		ResourceRef rr = getResourceRef();
		if(rr != null) {
			String path = rr.getPath().toString();
			int slashBefore;
			if(path.endsWith(Path.SEPARATOR_STRING)) {
				slashBefore = path.lastIndexOf(Path.SEPARATOR_CHAR, path.length() - 2);
			} else {
				slashBefore = path.lastIndexOf(Path.SEPARATOR_CHAR);
			}
			String filename = path.substring(slashBefore + 1);
			if(filename.isEmpty()) throw new IllegalArgumentException("Invalid filename for file: " + path);
			// Strip extension if will not leave empty
			int lastDot = filename.lastIndexOf('.');
			if(lastDot > 0) filename = filename.substring(0, lastDot);
			return filename;
		}
		throw new IllegalStateException("Path not set");
	}
601617
def modify_filename_id(filename):
    """"""
    split_filename = os.path.splitext(filename)
    id_num_re = re.compile('(\(\d\))')
    id_num = re.findall(id_num_re, split_filename[-2])
    if id_num:
        new_id_num = int(id_num[-1].lstrip('(').rstrip(')')) + 1

        # Reconstruct filename with incremented id and its extension
        filename = ''.join((re.sub(id_num_re, '({0})'.format(new_id_num),
                                   split_filename[-2]), split_filename[-1]))
    else:
        split_filename = os.path.splitext(filename)

        # Reconstruct filename with new id and its extension
        filename = ''.join(('{0} (2)'.format(split_filename[-2]),
                            split_filename[-1]))
    return filename
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);
    }
  }
489996
private function timber_generate_sizes( $attachment_id ) {
		$sizes      = [];
		$img_sizes  = Helper::get_image_sizes();
		$attachment = get_post( $attachment_id );

		/**
		 * Never automatically generate image sizes on upload for SVG and GIF images.
		 * SVG and GIF images will still be resized when requested on the fly.
		 */
		if ( in_array( $attachment->post_mime_type, array(
			'image/svg+xml',
			'image/gif',
		), true ) ) {
			return $sizes;
		}

		// Timber needs the file src as an URL
		$file_src  = wp_get_attachment_url( $attachment_id );
		$meta_data = wp_get_attachment_metadata( $attachment_id );

		/**
		 * Delete all existing image sizes for that file.
		 *
		 * This way, when Regenerate Thumbnails will be used, all non-registered image sizes will be
		 * deleted as well. Because Timber creates image sizes when they’re needed, we can safely do
		 * this.
		 */
		Timber\ImageHelper::delete_generated_files( $file_src );

		foreach ( $img_sizes as $key => $img_size ) {
			if ( ! $this->timber_should_resize( $attachment->post_parent, $img_size ) ) {
				continue;
			}

			// Create downsized version of the image
			$downsized = image_downsize( $attachment_id, $key );

			// Bail out if there was an error while downsizing the image.
			if ( ! is_array( $downsized ) ) {
				continue;
			}

			list( $file_src, $file_width, $file_height ) = $downsized;

			/**
			 * Create an image definition array that will be used for attachment metadata.
			 *
			 * WordPress saves an array with the file src, the width, the height and the mime type
			 * of an attachment in the postmeta database table. By generating this array and saving
			 * it in the database, we can improve the compatibility with the core image
			 * functionality.
			 *
			 * Correct width and height values of '0' by calculating them from the original image
			 * ratio, if meta data is available.
			 */
			if ( ! empty( $meta_data['height'] ) && ! empty( $meta_data['width'] ) ) {
				if ( 0 === (int) $file_width && ! empty( $meta_data['height'] ) ) {
					$file_width = round( $file_height / $meta_data['height'] * $meta_data['width'] );
				} elseif ( 0 === (int) $file_height ) {
					$file_height = round( $file_width / $meta_data['width'] * $meta_data['height'] );
				}
			}

			if ( is_numeric( $file_width ) && is_numeric( $file_height ) ) {
				$sizes[ $key ] = [
					'file'      => wp_basename( $file_src ),
					'width'     => $file_width,
					'height'    => $file_height,
					'mime-type' => wp_check_filetype( $file_src )['type'],
				];
			}

			/**
			 * Filters whether srcset sizes should be generated when an image is uploaded.
			 *
			 * @since 0.13.0
			 *
			 * @param bool     $generate_srcset_sizes Whether to generate srcset sizes. Passing false will prevent
			 *                                        srcset sizes to generated when an image is uploaded. Default false.
			 * @param string   $key                   The image size key.
			 * @param array    $img_size              The image size configuration array.
			 * @param \WP_Post $attachment            The attachment post.
			 */
			$generate_srcset_sizes = apply_filters( 'timmy/generate_srcset_sizes', false, $key, $img_size, $attachment );

			// Get setting from image configuration.
			$generate_srcset_sizes = isset( $img_size['generate_srcset_sizes'] )
				? $img_size['generate_srcset_sizes']
				: $generate_srcset_sizes;

			if ( false === $generate_srcset_sizes ) {
				continue;
			}

			// Get values for the default image
			$crop  = Helper::get_crop_for_size( $img_size );
			$force = Helper::get_force_for_size( $img_size );

			// Generate additional image sizes used for srcset
			if ( isset( $img_size['srcset'] ) ) {
				foreach ( $img_size['srcset'] as $srcset_size ) {
					list( $width, $height ) = Helper::get_dimensions_for_srcset_size( $img_size['resize'], $srcset_size );

					// For the new source, we use the same $crop and $force values as the default image
					self::resize( $img_size, $file_src, $width, $height, $crop, $force );
				}
			}
		}

		return $sizes;
	}
1228401
protected String convertToFullFilename(String relpath_or_package, String filename, String domain) throws Exception {

        if (relpath_or_package != null && ".".equals(relpath_or_package.trim())) {
            log.warn("******** BUG IN FilenameUtils ==============> " + normalize(relpath_or_package.replace('.', separatorChar) + separatorChar + filename));

            throw new Exception("not a good practice, please clean up your template relative path, you may set it to empty string... :" + relpath_or_package
                    + ", " + filename);
        }

        String ret;

        if (hasLength(relpath_or_package)) {
            ret = normalize(relpath_or_package.replace('.', separatorChar) + separatorChar + filename);
        } else {
            ret = filename;
        }

        if (hasLength(domain)) {
            return normalize(domain + File.separator + ret);
        } else {
            return ret;
        }
    }
886069
@Override
	public void setFileExtension(final String fileExtension) {
		if (fileExtension == null) {
			LOG.warn("Use the default value because SQL template extension is set to NULL.");
			LOG.warn("Default SQL template extension[{}]", DEFAULT_FILE_EXTENSION);
			this.fileExtension = DEFAULT_FILE_EXTENSION;
		} else {
			this.fileExtension = fileExtension;
		}
	}
539191
function getImageSizeForSource(editor, src, callback) {
		var fileContent;
		if (src) {
			// check if it is data:url
			if (/^data:/.test(src)) {
				fileContent = base64.decode( src.replace(/^data\:.+?;.+?,/, '') );
				return callback(actionUtils.getImageSize(fileContent));
			}

			var filePath = editor.getFilePath();
			file.locateFile(filePath, src, function(absPath) {
				if (absPath === null) {
					throw "Can't find " + src + ' file';
				}

				file.read(absPath, function(err, content) {
					if (err) {
						throw 'Unable to read ' + absPath + ': ' + err;
					}

					content = String(content);
					callback(actionUtils.getImageSize(content));
				});
			});
		}
	}
85128
function truncate($filename, $new_size)
    {
        $attr = pack('N3', NET_SFTP_ATTR_SIZE, $new_size / 4294967296, $new_size); // 4294967296 == 0x100000000 == 1<<32

        return $this->_setstat($filename, $attr, false);
    }
1066092
def size(pathname):
    
    if os.path.isfile(pathname):
        return os.path.getsize(pathname)
    return sum([size('{}/{}'.format(pathname, name)) for name in get_content_list(pathname)])
1029186
def disk_check_size(ctx, param, value):
    
    if value:
        # if we've got a prefix
        if isinstance(value, tuple):
            val = value[1]
        else:
            val = value
        if val % 1024:
            raise click.ClickException('Size must be a multiple of 1024.')
    return value
675
private static String doNormalizeIgnoreOtherSeparator(String filename, boolean keepSeparator) {
		if (filename == null) {
			return null;
		}
		int size = filename.length();
		if (size == 0) {
			return filename;
		}
		int prefix = 0;
		// int prefix = getPrefixLength(filename);
		// if (prefix < 0) {
		// return null;
		// }

		char[] array = new char[size + 2]; // +1 for possible extra slash, +2
											// for arraycopy
		filename.getChars(0, filename.length(), array, 0);

		// add extra separator on the end to simplify code below
		boolean lastIsDirectory = true;
		if (array[size - 1] != JawrConstant.URL_SEPARATOR_CHAR) {
			array[size++] = JawrConstant.URL_SEPARATOR_CHAR;
			lastIsDirectory = false;
		}

		// adjoining slashes
		for (int i = prefix + 1; i < size; i++) {
			if (array[i] == JawrConstant.URL_SEPARATOR_CHAR && array[i - 1] == JawrConstant.URL_SEPARATOR_CHAR) {
				System.arraycopy(array, i, array, i - 1, size - i);
				size--;
				i--;
			}
		}

		// dot slash
		for (int i = prefix + 1; i < size; i++) {
			if (array[i] == JawrConstant.URL_SEPARATOR_CHAR && array[i - 1] == '.'
					&& (i == prefix + 1 || array[i - 2] == JawrConstant.URL_SEPARATOR_CHAR)) {
				if (i == size - 1) {
					lastIsDirectory = true;
				}
				System.arraycopy(array, i + 1, array, i - 1, size - i);
				size -= 2;
				i--;
			}
		}

		// double dot slash
		outer: for (int i = prefix + 2; i < size; i++) {
			if (array[i] == JawrConstant.URL_SEPARATOR_CHAR && array[i - 1] == '.' && array[i - 2] == '.'
					&& (i == prefix + 2 || array[i - 3] == JawrConstant.URL_SEPARATOR_CHAR)) {
				if (i == prefix + 2) {
					return null;
				}
				if (i == size - 1) {
					lastIsDirectory = true;
				}
				int j;
				for (j = i - 4; j >= prefix; j--) {
					if (array[j] == JawrConstant.URL_SEPARATOR_CHAR) {
						// remove b/../ from a/b/../c
						System.arraycopy(array, i + 1, array, j + 1, size - i);
						size -= (i - j);
						i = j + 1;
						continue outer;
					}
				}
				// remove a/../ from a/../c
				System.arraycopy(array, i + 1, array, prefix, size - i);
				size -= (i + 1 - prefix);
				i = prefix + 1;
			}
		}

		if (size <= 0) { // should never be less than 0
			return "";
		}
		if (size <= prefix) { // should never be less than prefix
			return new String(array, 0, size);
		}
		if (lastIsDirectory && keepSeparator) {
			return new String(array, 0, size); // keep trailing separator
		}
		return new String(array, 0, size - 1); // lose trailing separator
	}
878479
def skip_id3(fileobj):
    """"""

    # WMP writes multiple id3s, so skip as many as we find
    while True:
        idata = fileobj.read(10)
        try:
            id3, insize = struct.unpack('>3sxxx4s', idata)
        except struct.error:
            id3, insize = b'', 0
        insize = BitPaddedInt(insize)
        if id3 == b'ID3' and insize > 0:
            fileobj.seek(insize, 1)
        else:
            fileobj.seek(-len(idata), 1)
            break
980904
public static int sizeOfIA5String(String value) {
        return DerUtils.sizeOf(ASN1_IA5STRING_TAG_NUM, (value == null) ? 0 : value.getBytes().length);
    }
1087825
@Override
    public int size(boolean includeDiskCache) {
        int mappings = 0;

        mappings = cache.getNumberCacheEntries();

        if (includeDiskCache) {
            if (cache instanceof CacheProviderWrapper) {
                CacheProviderWrapper cpw = (CacheProviderWrapper) cache;
                if (cpw.featureSupport.isDiskCacheSupported())
                    mappings = mappings + cache.getIdsSizeDisk();
            } else {
                mappings = mappings + cache.getIdsSizeDisk();
            }
        }
        return mappings;
    }
459646
private int getSize() {

        return Integer.valueOf(
            (String)CmsVaadinUtils.getRequest().getSession().getAttribute(ATTR_FILE_VIEW_SIZE)).intValue();
    }
879192
public long getSize(String filename)
        throws IOException, ServerException {
        if (filename == null) {
            throw new IllegalArgumentException("Required argument missing");
        }
        Command cmd = new Command("SIZE", filename);
        Reply reply = null;
        try {
            reply = controlChannel.execute(cmd);
            return Long.parseLong(reply.getMessage());
        } catch (NumberFormatException e) {
            throw ServerException.embedFTPReplyParseException(
                         new FTPReplyParseException(
                                FTPReplyParseException.MESSAGE_UNPARSABLE,
                               "Could not parse size: " + reply.getMessage()));
        } catch (UnexpectedReplyCodeException urce) {
            throw ServerException.embedUnexpectedReplyCodeException(urce);
        } catch (FTPReplyParseException rpe) {
            throw ServerException.embedFTPReplyParseException(rpe);
        }
    }
609733
function getIdStringFromIdParts(source, idParts) {
        if (idParts.length === 1) {
            return null;
        }
        var i, l, idPart, idPartType, check = 0, nextIdNameCode;
        for (i = 0, l = idParts.length; i < l; i++) {
            if (idParts[i].type) {
                check = 1;
                break;
            }
        }
        if (check) {
            var ret = [];
            for (i = 0, l = idParts.length; i < l; i++) {
                idPart = idParts[i];
                idPartType = idPart.type;
                if (idPartType) {
                    nextIdNameCode = xtplAstToJs[idPartType](idPart);
                    pushToArray(source, nextIdNameCode.source);
                    ret.push(nextIdNameCode.exp);
                } else {
                    // literal a.x
                    ret.push(wrapByDoubleQuote(idPart));
                }
            }
            return ret;
        } else {
            return null;
        }
    }