mime_util_xdg.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef BASE_NIX_MIME_UTIL_XDG_H_
  5. #define BASE_NIX_MIME_UTIL_XDG_H_
  6. #include <string>
  7. #include "base/base_export.h"
  8. #include "build/build_config.h"
  9. namespace base {
  10. class FilePath;
  11. namespace nix {
  12. // Gets the mime type for a file at |filepath|.
  13. //
  14. // The mime type is calculated based only on the file name of |filepath|. In
  15. // particular |filepath| will not be touched on disk and |filepath| doesn't even
  16. // have to exist. This means that the function does not work for directories
  17. // (i.e. |filepath| is assumed to be a path to a file).
  18. //
  19. // Note that this function might need to read from disk the mime-types data
  20. // provided by the OS. Therefore this function should not be called from
  21. // threads that disallow IO via base::ThreadRestrictions::SetIOAllowed(false).
  22. //
  23. // If the mime type is unknown, this will return application/octet-stream.
  24. BASE_EXPORT std::string GetFileMimeType(const FilePath& filepath);
  25. } // namespace nix
  26. } // namespace base
  27. #endif // BASE_NIX_MIME_UTIL_XDG_H_