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

Unified Diff: base/file_util_win.cc

Issue 4431001: Revert 64960 - Turn on file access checks on Win.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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/base.gypi ('k') | base/file_version_info_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_win.cc
===================================================================
--- base/file_util_win.cc (revision 64973)
+++ base/file_util_win.cc (working copy)
@@ -19,7 +19,6 @@
#include "base/win/scoped_handle.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
-#include "base/thread_restrictions.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "base/win_util.h"
@@ -36,8 +35,6 @@
// Helper for NormalizeFilePath(), defined below.
bool DevicePathToDriveLetterPath(const FilePath& device_path,
FilePath* drive_letter_path) {
- base::ThreadRestrictions::AssertIOAllowed();
-
// Get the mapping of drive letters to device paths.
const int kDriveMappingSize = 1024;
wchar_t drive_mapping[kDriveMappingSize] = {'\0'};
@@ -78,7 +75,6 @@
} // namespace
std::wstring GetDirectoryFromPath(const std::wstring& path) {
- base::ThreadRestrictions::AssertIOAllowed();
wchar_t path_buffer[MAX_PATH];
wchar_t* file_ptr = NULL;
if (GetFullPathName(path.c_str(), MAX_PATH, path_buffer, &file_ptr) == 0)
@@ -91,7 +87,6 @@
}
bool AbsolutePath(FilePath* path) {
- base::ThreadRestrictions::AssertIOAllowed();
wchar_t file_path_buf[MAX_PATH];
if (!_wfullpath(file_path_buf, path->value().c_str(), MAX_PATH))
return false;
@@ -101,8 +96,6 @@
int CountFilesCreatedAfter(const FilePath& path,
const base::Time& comparison_time) {
- base::ThreadRestrictions::AssertIOAllowed();
-
int file_count = 0;
FILETIME comparison_filetime(comparison_time.ToFileTime());
@@ -130,8 +123,6 @@
}
bool Delete(const FilePath& path, bool recursive) {
- base::ThreadRestrictions::AssertIOAllowed();
-
if (path.value().length() >= MAX_PATH)
return false;
@@ -170,8 +161,6 @@
}
bool DeleteAfterReboot(const FilePath& path) {
- base::ThreadRestrictions::AssertIOAllowed();
-
if (path.value().length() >= MAX_PATH)
return false;
@@ -181,8 +170,6 @@
}
bool Move(const FilePath& from_path, const FilePath& to_path) {
- base::ThreadRestrictions::AssertIOAllowed();
-
// NOTE: I suspect we could support longer paths, but that would involve
// analyzing all our usage of files.
if (from_path.value().length() >= MAX_PATH ||
@@ -202,8 +189,6 @@
}
bool ReplaceFile(const FilePath& from_path, const FilePath& to_path) {
- base::ThreadRestrictions::AssertIOAllowed();
-
// Make sure that the target file exists.
HANDLE target_file = ::CreateFile(
to_path.value().c_str(),
@@ -223,8 +208,6 @@
}
bool CopyFile(const FilePath& from_path, const FilePath& to_path) {
- base::ThreadRestrictions::AssertIOAllowed();
-
// NOTE: I suspect we could support longer paths, but that would involve
// analyzing all our usage of files.
if (from_path.value().length() >= MAX_PATH ||
@@ -237,8 +220,6 @@
bool ShellCopy(const FilePath& from_path, const FilePath& to_path,
bool recursive) {
- base::ThreadRestrictions::AssertIOAllowed();
-
// NOTE: I suspect we could support longer paths, but that would involve
// analyzing all our usage of files.
if (from_path.value().length() >= MAX_PATH ||
@@ -270,8 +251,6 @@
bool CopyDirectory(const FilePath& from_path, const FilePath& to_path,
bool recursive) {
- base::ThreadRestrictions::AssertIOAllowed();
-
if (recursive)
return ShellCopy(from_path, to_path, true);
@@ -295,7 +274,6 @@
bool CopyAndDeleteDirectory(const FilePath& from_path,
const FilePath& to_path) {
- base::ThreadRestrictions::AssertIOAllowed();
if (CopyDirectory(from_path, to_path, true)) {
if (Delete(from_path, true)) {
return true;
@@ -310,12 +288,10 @@
bool PathExists(const FilePath& path) {
- base::ThreadRestrictions::AssertIOAllowed();
return (GetFileAttributes(path.value().c_str()) != INVALID_FILE_ATTRIBUTES);
}
bool PathIsWritable(const FilePath& path) {
- base::ThreadRestrictions::AssertIOAllowed();
HANDLE dir =
CreateFile(path.value().c_str(), FILE_ADD_FILE, kFileShareAll,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
@@ -328,7 +304,6 @@
}
bool DirectoryExists(const FilePath& path) {
- base::ThreadRestrictions::AssertIOAllowed();
DWORD fileattr = GetFileAttributes(path.value().c_str());
if (fileattr != INVALID_FILE_ATTRIBUTES)
return (fileattr & FILE_ATTRIBUTE_DIRECTORY) != 0;
@@ -337,7 +312,6 @@
bool GetFileCreationLocalTimeFromHandle(HANDLE file_handle,
LPSYSTEMTIME creation_time) {
- base::ThreadRestrictions::AssertIOAllowed();
if (!file_handle)
return false;
@@ -354,7 +328,6 @@
bool GetFileCreationLocalTime(const std::wstring& filename,
LPSYSTEMTIME creation_time) {
- base::ThreadRestrictions::AssertIOAllowed();
base::win::ScopedHandle file_handle(
CreateFile(filename.c_str(), GENERIC_READ, kFileShareAll, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL));
@@ -362,8 +335,6 @@
}
bool ResolveShortcut(FilePath* path) {
- base::ThreadRestrictions::AssertIOAllowed();
-
HRESULT result;
base::win::ScopedComPtr<IShellLink> i_shell_link;
bool is_resolved = false;
@@ -399,8 +370,6 @@
const wchar_t *working_dir, const wchar_t *arguments,
const wchar_t *description, const wchar_t *icon,
int icon_index, const wchar_t* app_id) {
- base::ThreadRestrictions::AssertIOAllowed();
-
// Length of arguments and description must be less than MAX_PATH.
DCHECK(lstrlen(arguments) < MAX_PATH);
DCHECK(lstrlen(description) < MAX_PATH);
@@ -452,8 +421,6 @@
const wchar_t *working_dir, const wchar_t *arguments,
const wchar_t *description, const wchar_t *icon,
int icon_index, const wchar_t* app_id) {
- base::ThreadRestrictions::AssertIOAllowed();
-
// Length of arguments and description must be less than MAX_PATH.
DCHECK(lstrlen(arguments) < MAX_PATH);
DCHECK(lstrlen(description) < MAX_PATH);
@@ -500,8 +467,6 @@
}
bool TaskbarPinShortcutLink(const wchar_t* shortcut) {
- base::ThreadRestrictions::AssertIOAllowed();
-
// "Pin to taskbar" is only supported after Win7.
if (base::win::GetVersion() < base::win::VERSION_WIN7)
return false;
@@ -512,8 +477,6 @@
}
bool TaskbarUnpinShortcutLink(const wchar_t* shortcut) {
- base::ThreadRestrictions::AssertIOAllowed();
-
// "Unpin from taskbar" is only supported after Win7.
if (base::win::GetVersion() < base::win::VERSION_WIN7)
return false;
@@ -524,8 +487,6 @@
}
bool GetTempDir(FilePath* path) {
- base::ThreadRestrictions::AssertIOAllowed();
-
wchar_t temp_path[MAX_PATH + 1];
DWORD path_len = ::GetTempPath(MAX_PATH, temp_path);
if (path_len >= MAX_PATH || path_len <= 0)
@@ -542,8 +503,6 @@
}
bool CreateTemporaryFile(FilePath* path) {
- base::ThreadRestrictions::AssertIOAllowed();
-
FilePath temp_file;
if (!GetTempDir(path))
@@ -558,7 +517,6 @@
}
FILE* CreateAndOpenTemporaryShmemFile(FilePath* path) {
- base::ThreadRestrictions::AssertIOAllowed();
return CreateAndOpenTemporaryFile(path);
}
@@ -567,7 +525,6 @@
// TODO(jrg): is there equivalent call to use on Windows instead of
// going 2-step?
FILE* CreateAndOpenTemporaryFileInDir(const FilePath& dir, FilePath* path) {
- base::ThreadRestrictions::AssertIOAllowed();
if (!CreateTemporaryFileInDir(dir, path)) {
return NULL;
}
@@ -579,8 +536,6 @@
bool CreateTemporaryFileInDir(const FilePath& dir,
FilePath* temp_file) {
- base::ThreadRestrictions::AssertIOAllowed();
-
wchar_t temp_name[MAX_PATH + 1];
if (!GetTempFileName(dir.value().c_str(), L"", 0, temp_name)) {
@@ -603,8 +558,6 @@
bool CreateTemporaryDirInDir(const FilePath& base_dir,
const FilePath::StringType& prefix,
FilePath* new_dir) {
- base::ThreadRestrictions::AssertIOAllowed();
-
FilePath path_to_create;
srand(static_cast<uint32>(time(NULL)));
@@ -629,8 +582,6 @@
bool CreateNewTempDirectory(const FilePath::StringType& prefix,
FilePath* new_temp_path) {
- base::ThreadRestrictions::AssertIOAllowed();
-
FilePath system_temp_dir;
if (!GetTempDir(&system_temp_dir))
return false;
@@ -639,8 +590,6 @@
}
bool CreateDirectory(const FilePath& full_path) {
- base::ThreadRestrictions::AssertIOAllowed();
-
// If the path exists, we've succeeded if it's a directory, failed otherwise.
const wchar_t* full_path_str = full_path.value().c_str();
DWORD fileattr = ::GetFileAttributes(full_path_str);
@@ -687,8 +636,6 @@
}
bool GetFileInfo(const FilePath& file_path, base::PlatformFileInfo* results) {
- base::ThreadRestrictions::AssertIOAllowed();
-
WIN32_FILE_ATTRIBUTE_DATA attr;
if (!GetFileAttributesEx(file_path.value().c_str(),
GetFileExInfoStandard, &attr)) {
@@ -710,18 +657,15 @@
}
FILE* OpenFile(const FilePath& filename, const char* mode) {
- base::ThreadRestrictions::AssertIOAllowed();
std::wstring w_mode = ASCIIToWide(std::string(mode));
return _wfsopen(filename.value().c_str(), w_mode.c_str(), _SH_DENYNO);
}
FILE* OpenFile(const std::string& filename, const char* mode) {
- base::ThreadRestrictions::AssertIOAllowed();
return _fsopen(filename.c_str(), mode, _SH_DENYNO);
}
int ReadFile(const FilePath& filename, char* data, int size) {
- base::ThreadRestrictions::AssertIOAllowed();
base::win::ScopedHandle file(CreateFile(filename.value().c_str(),
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
@@ -740,7 +684,6 @@
}
int WriteFile(const FilePath& filename, const char* data, int size) {
- base::ThreadRestrictions::AssertIOAllowed();
base::win::ScopedHandle file(CreateFile(filename.value().c_str(),
GENERIC_WRITE,
0,
@@ -775,8 +718,6 @@
bool RenameFileAndResetSecurityDescriptor(const FilePath& source_file_path,
const FilePath& target_file_path) {
- base::ThreadRestrictions::AssertIOAllowed();
-
// The parameters to SHFileOperation must be terminated with 2 NULL chars.
std::wstring source = source_file_path.value();
std::wstring target = target_file_path.value();
@@ -799,8 +740,6 @@
// Gets the current working directory for the process.
bool GetCurrentDirectory(FilePath* dir) {
- base::ThreadRestrictions::AssertIOAllowed();
-
wchar_t system_buffer[MAX_PATH];
system_buffer[0] = 0;
DWORD len = ::GetCurrentDirectory(MAX_PATH, system_buffer);
@@ -816,7 +755,6 @@
// Sets the current working directory for the process.
bool SetCurrentDirectory(const FilePath& directory) {
- base::ThreadRestrictions::AssertIOAllowed();
BOOL ret = ::SetCurrentDirectory(directory.value().c_str());
return ret != 0;
}
@@ -874,8 +812,6 @@
}
FilePath FileEnumerator::Next() {
- base::ThreadRestrictions::AssertIOAllowed();
-
while (has_find_data_ || !pending_paths_.empty()) {
if (!has_find_data_) {
// The last find FindFirstFile operation is done, prepare a new one.
@@ -947,8 +883,6 @@
}
bool MemoryMappedFile::MapFileToMemoryInternal() {
- base::ThreadRestrictions::AssertIOAllowed();
-
if (file_ == INVALID_HANDLE_VALUE)
return false;
@@ -992,14 +926,12 @@
bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info,
const base::Time& cutoff_time) {
- base::ThreadRestrictions::AssertIOAllowed();
long result = CompareFileTime(&find_info.ftLastWriteTime,
&cutoff_time.ToFileTime());
return result == 1 || result == 0;
}
bool NormalizeFilePath(const FilePath& path, FilePath* real_path) {
- base::ThreadRestrictions::AssertIOAllowed();
FilePath mapped_file;
if (!NormalizeToNativeFilePath(path, &mapped_file))
return false;
@@ -1011,7 +943,6 @@
}
bool NormalizeToNativeFilePath(const FilePath& path, FilePath* nt_path) {
- base::ThreadRestrictions::AssertIOAllowed();
// In Vista, GetFinalPathNameByHandle() would give us the real path
// from a file handle. If we ever deprecate XP, consider changing the
// code below to a call to GetFinalPathNameByHandle(). The method this
@@ -1067,7 +998,6 @@
bool PreReadImage(const wchar_t* file_path, size_t size_to_read,
size_t step_size) {
- base::ThreadRestrictions::AssertIOAllowed();
if (base::win::GetVersion() > base::win::VERSION_XP) {
// Vista+ branch. On these OSes, the forced reads through the DLL actually
// slows warm starts. The solution is to sequentially read file contents
« no previous file with comments | « base/base.gypi ('k') | base/file_version_info_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698