Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Luckily, chromium is open source so you can look into the well-documented code. Ok... I found it: <a href="https://code.google.com/p/chromium/codesearch#chromium/src/content/browser/download/download_file_impl.cc&amp;sq=package%3achromium&amp;type=cs&amp;l=104&amp;rcl=1364340364" rel="nofollow">here</a></p> <p><code>RenameAndUniquify</code> is:</p> <pre><code>void DownloadFileImpl::RenameAndUniquify( const base::FilePath&amp; full_path, const RenameCompletionCallback&amp; callback) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); base::FilePath new_path(full_path); int uniquifier = file_util::GetUniquePathNumber(new_path, FILE_PATH_LITERAL("")); if (uniquifier &gt; 0) { new_path = new_path.InsertBeforeExtensionASCII( base::StringPrintf(" (%d)", uniquifier)); } ... } </code></pre> <p>and <code>InsertBeforeExtension</code> calls <code>ExtensionSeperatorPosition</code> which interests you (<a href="https://code.google.com/p/chromium/codesearch#chromium/src/base/files/file_path.cc&amp;sq=package%3achromium&amp;type=cs&amp;l=126&amp;rcl=1364340364" rel="nofollow">link</a>):</p> <pre><code>// Find the position of the '.' that separates the extension from the rest // of the file name. The position is relative to BaseName(), not value(). // This allows a second extension component of up to 4 characters when the // rightmost extension component is a common double extension (gz, bz2, Z). // For example, foo.tar.gz or foo.tar.Z would have extension components of // '.tar.gz' and '.tar.Z' respectively. Returns npos if it can't find an // extension. StringType::size_type ExtensionSeparatorPosition(const StringType&amp; path) { // Special case "." and ".." if (path == FilePath::kCurrentDirectory || path == FilePath::kParentDirectory) return StringType::npos; const StringType::size_type last_dot = path.rfind(FilePath::kExtensionSeparator); // No extension, or the extension is the whole filename. if (last_dot == StringType::npos || last_dot == 0U) return last_dot; const StringType::size_type penultimate_dot = path.rfind(FilePath::kExtensionSeparator, last_dot - 1); const StringType::size_type last_separator = path.find_last_of(FilePath::kSeparators, last_dot - 1, arraysize(FilePath::kSeparators) - 1); if (penultimate_dot == StringType::npos || (last_separator != StringType::npos &amp;&amp; penultimate_dot &lt; last_separator)) { return last_dot; } for (size_t i = 0; i &lt; arraysize(kCommonDoubleExtensions); ++i) { StringType extension(path, penultimate_dot + 1); if (LowerCaseEqualsASCII(extension, kCommonDoubleExtensions[i])) return penultimate_dot; } StringType extension(path, last_dot + 1); for (size_t i = 0; i &lt; arraysize(kCommonDoubleExtensionSuffixes); ++i) { if (LowerCaseEqualsASCII(extension, kCommonDoubleExtensionSuffixes[i])) { if ((last_dot - penultimate_dot) &lt;= 5U &amp;&amp; (last_dot - penultimate_dot) &gt; 1U) { return penultimate_dot; } } } return last_dot; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload