From a202343b6dd492bea383f9babc427dfa2e274b7d Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Wed, 6 Nov 2024 17:33:14 +0000 Subject: Consolidate the use of some constants. Bug: 377474232 Test: atest ArtServiceTests Test: atest art_standalone_artd_tests Test: atest art_standalone_odrefresh_tests Test: atest art_standalone_libartbase_tests Test: atest art_standalone_runtime_tests Test: atest art_standalone_dex2oat_tests Change-Id: I66a29ea85176c6c6d676537fe6e4e64152360acc --- libartbase/base/file_utils.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libartbase/base/file_utils.h') diff --git a/libartbase/base/file_utils.h b/libartbase/base/file_utils.h index 205cc6115d..8a25fe1d9f 100644 --- a/libartbase/base/file_utils.h +++ b/libartbase/base/file_utils.h @@ -33,7 +33,11 @@ static constexpr const char kArtApexDataDefaultPath[] = "/data/misc/apexdata/com static constexpr const char kAndroidConscryptApexDefaultPath[] = "/apex/com.android.conscrypt"; static constexpr const char kAndroidI18nApexDefaultPath[] = "/apex/com.android.i18n"; -static constexpr const char kArtImageExtension[] = "art"; +static constexpr const char* kOatExtension = ".oat"; +static constexpr const char* kOdexExtension = ".odex"; +static constexpr const char* kVdexExtension = ".vdex"; +static constexpr const char* kArtExtension = ".art"; +static constexpr const char* kDmExtension = ".dm"; // These methods return the Android Root, which is the historical location of // the Android "system" directory, containing the built Android artifacts. On @@ -176,8 +180,11 @@ std::string GetSystemOdexFilenameForApex(std::string_view location, InstructionS // Returns `filename` with the text after the last occurrence of '.' replaced with // `extension`. If `filename` does not contain a period, returns a string containing `filename`, // a period, and `new_extension`. +// A leading period in `new_extension`, if exists, is ignored. // Example: ReplaceFileExtension("foo.bar", "abc") == "foo.abc" // ReplaceFileExtension("foo", "abc") == "foo.abc" +// ReplaceFileExtension("foo.bar", ".abc") == "foo.abc" +// ReplaceFileExtension("foo", ".abc") == "foo.abc" std::string ReplaceFileExtension(std::string_view filename, std::string_view new_extension); // Return whether the location is on /apex/com.android.art -- cgit v1.2.3-59-g8ed1b