other-licenses/7zstub/src/7zip/UI/Common/DefaultName.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 // DefaultName.cpp
     3 #include "StdAfx.h"
     5 #include "DefaultName.h"
     7 static const wchar_t *kEmptyFileAlias = L"[Content]";
     9 UString GetDefaultName2(const UString &fileName, 
    10     const UString &extension, const UString &addSubExtension)
    11 {
    12   int extLength = extension.Length();
    13   int fileNameLength = fileName.Length();
    14   if (fileNameLength > extLength + 1)
    15   {
    16     int dotPos = fileNameLength - (extLength + 1);
    17     if (fileName[dotPos] == '.')
    18       if (extension.CompareNoCase(fileName.Mid(dotPos + 1)) == 0)
    19         return fileName.Left(dotPos) + addSubExtension;
    20   }
    21   return kEmptyFileAlias;
    22 }

mercurial