chromium/extensions/browser/path_util.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "extensions/browser/path_util.h"

#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/path_service.h"
#include "base/strings/sys_string_conversions.h"
#include "build/build_config.h"
#include "extensions/browser/extension_file_task_runner.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/text/bytes_formatting.h"

#if BUILDFLAG(IS_MAC)
#include <CoreFoundation/CoreFoundation.h>
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
#endif

namespace extensions {
namespace path_util {

namespace {
#if BUILDFLAG(IS_MAC)

// Retrieves the localized display name for the base name of the given path.
// If the path is not localized, this will just return the base name.
std::string GetDisplayBaseName(const base::FilePath& path) {
  base::apple::ScopedCFTypeRef<CFURLRef> url =
      base::apple::FilePathToCFURL(path);
  if (!url) {
    return path.BaseName().value();
  }

  base::apple::ScopedCFTypeRef<CFStringRef> str;
  if (!CFURLCopyResourcePropertyForKey(url.get(), kCFURLLocalizedNameKey,
                                       str.InitializeInto(),
                                       /*error=*/nullptr)) {
    return path.BaseName().value();
  }

  return base::SysCFStringRefToUTF8(str.get());
}

#endif  // BUILDFLAG(IS_MAC)

const base::FilePath::CharType kHomeShortcut[] =);

void OnDirectorySizeCalculated(
    int message_id,
    base::OnceCallback<void(const std::u16string&)> callback,
    int64_t size_in_bytes) {}

}  // namespace

base::FilePath PrettifyPath(const base::FilePath& source_path) {}

void CalculateExtensionDirectorySize(
    const base::FilePath& extension_path,
    base::OnceCallback<void(const int64_t)> callback) {}

void CalculateAndFormatExtensionDirectorySize(
    const base::FilePath& extension_path,
    int message_id,
    base::OnceCallback<void(const std::u16string&)> callback) {}

base::FilePath ResolveHomeDirectory(const base::FilePath& path) {}

}  // namespace path_util
}  // namespace extensions