Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2441)

Unified Diff: base/file_store.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_store.h ('k') | base/file_store_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_store.cc
diff --git a/base/file_store.cc b/base/file_store.cc
deleted file mode 100644
index 372c1b84bc0cbff613ef9628464b7f65e5b4b671..0000000000000000000000000000000000000000
--- a/base/file_store.cc
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright 2006-2009 Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-// ========================================================================
-//
-// Defines class FileStore
-
-#include <vector>
-#include "omaha/base/debug.h"
-#include "omaha/base/file.h"
-#include "omaha/base/file_store.h"
-#include "omaha/base/string.h"
-#include "omaha/base/utils.h"
-
-namespace omaha {
-
-// Open the store
-bool FileStore::Open(const TCHAR* file_path) {
- file_path_ = String_MakeEndWith(file_path, _T("\\"), false);
- return true;
-}
-
-// Close the store
-bool FileStore::Close() {
- file_path_.Empty();
- return true;
-}
-
-// Clear the store
-bool FileStore::Clear() {
- if (File::Exists(file_path_) && File::IsDirectory(file_path_)) {
- return SUCCEEDED(DeleteDirectoryFiles(file_path_));
- } else {
- return true;
- }
-}
-
-// Read a value from the store
-bool FileStore::Read(const TCHAR* name, std::vector<byte>* data) const {
- ASSERT1(name);
- ASSERT1(data);
-
- return Exists(name) && SUCCEEDED(ReadEntireFile(file_path_ + name, 0, data));
-}
-
-// Write a value to the store
-bool FileStore::Write(const TCHAR* name, byte* data, int data_size) {
- ASSERT1(name);
- ASSERT1(data);
- ASSERT1(data_size);
-
- std::vector<byte> buffer(data_size);
- memcpy(&buffer.front(), data, data_size);
-
- return SUCCEEDED(WriteEntireFile(file_path_ + name, buffer));
-}
-
-// Check to see a named value exists in the store
-bool FileStore::Exists(const TCHAR* name) const {
- ASSERT1(name);
-
- return File::Exists(file_path_ + name);
-}
-
-// Remove a value from the store
-bool FileStore::Remove(const TCHAR* name) {
- ASSERT1(name);
-
- return SUCCEEDED(File::Remove(file_path_ + name));
-}
-
-// Get the number of values for this store
-bool FileStore::GetValueCount(uint32* value_count) {
- ASSERT1(value_count);
-
- std::vector<CString> matching_paths;
-
- if (FAILED(File::GetWildcards(file_path_, _T("*"), &matching_paths))) {
- return false;
- }
-
- *value_count = matching_paths.size();
-
- return true;
-}
-
-// Get the value name for the given value name index
-bool FileStore::GetValueNameAt(uint32 index, CString* value_name) {
- ASSERT1(value_name);
-
- std::vector<CString> matching_paths;
-
- if (FAILED(File::GetWildcards(file_path_, _T("*"), &matching_paths))) {
- return false;
- }
- if (index >= matching_paths.size()) {
- return false;
- }
-
- *value_name = matching_paths[index].Mid(file_path_.GetLength());
-
- return true;
-}
-
-} // namespace omaha
-
« no previous file with comments | « base/file_store.h ('k') | base/file_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698