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

Side by Side Diff: base/file_util.h

Issue 10914109: Refactoring and tests for the highly undertested file_util::CreateOrUpdateShortcutLink() method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: namespace s/Win/win Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/base.gypi ('k') | base/file_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains utility functions for dealing with the local 5 // This file contains utility functions for dealing with the local
6 // filesystem. 6 // filesystem.
7 7
8 #ifndef BASE_FILE_UTIL_H_ 8 #ifndef BASE_FILE_UTIL_H_
9 #define BASE_FILE_UTIL_H_ 9 #define BASE_FILE_UTIL_H_
10 10
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // a file which the symlink points to. 219 // a file which the symlink points to.
220 BASE_EXPORT bool GetPosixFilePermissions(const FilePath& path, 220 BASE_EXPORT bool GetPosixFilePermissions(const FilePath& path,
221 int* mode); 221 int* mode);
222 // Sets the permission of the given |path|. If |path| is symbolic link, sets 222 // Sets the permission of the given |path|. If |path| is symbolic link, sets
223 // the permission of a file which the symlink points to. 223 // the permission of a file which the symlink points to.
224 BASE_EXPORT bool SetPosixFilePermissions(const FilePath& path, 224 BASE_EXPORT bool SetPosixFilePermissions(const FilePath& path,
225 int mode); 225 int mode);
226 #endif // defined(OS_POSIX) 226 #endif // defined(OS_POSIX)
227 227
228 #if defined(OS_WIN) 228 #if defined(OS_WIN)
229 enum ShortcutOptions {
230 SHORTCUT_NO_OPTIONS = 0,
231 // Set DualMode property for Windows 8 Metro-enabled shortcuts.
232 SHORTCUT_DUAL_MODE = 1 << 0,
233 // Create a new shortcut (overwriting if necessary).
234 SHORTCUT_CREATE_ALWAYS = 1 << 1,
235 };
236
237 // Resolve Windows shortcut (.LNK file)
238 // This methods tries to resolve a shortcut .LNK file. The path of the shortcut
239 // to resolve is in |shortcut_path|. If |target_path| is not NULL, the target
240 // will be resolved and placed in |target_path|. If |args| is not NULL, the
241 // arguments will be retrieved and placed in |args|. The function returns true
242 // if all requested fields are are found successfully.
243 // Callers can safely use the same variable for both |shortcut_path| and
244 // |target_path|.
245 BASE_EXPORT bool ResolveShortcut(const FilePath& shortcut_path,
246 FilePath* target_path,
247 string16* args);
248
249 // Creates (or updates) a Windows shortcut (.LNK file)
250 // This method creates (or updates) a shortcut link using the information given.
251 // Ensure you have initialized COM before calling into this function.
252 // |destination| is required. |source| is required when SHORTCUT_CREATE_ALWAYS
253 // is specified in |options|. All other parameters are optional and may be NULL.
254 // |source| is the existing file, |destination| is the new link file to be
255 // created; for best results pass the filename with the .lnk extension.
256 // The |icon| can specify a dll or exe in which case the icon index is the
257 // resource id. |app_id| is the app model id for the shortcut on Win7.
258 // |options|: bitfield for which the options come from ShortcutOptions.
259 // If SHORTCUT_CREATE_ALWAYS is not set in |options|, only specified (non-null)
260 // properties on an existing shortcut will be modified. If the shortcut does not
261 // exist, this method is a no-op and returns false.
262 BASE_EXPORT bool CreateOrUpdateShortcutLink(const wchar_t *source,
263 const wchar_t *destination,
264 const wchar_t *working_dir,
265 const wchar_t *arguments,
266 const wchar_t *description,
267 const wchar_t *icon,
268 int icon_index,
269 const wchar_t* app_id,
270 uint32 options);
271
272 // Pins a shortcut to the Windows 7 taskbar. The shortcut file must already
273 // exist and be a shortcut that points to an executable.
274 BASE_EXPORT bool TaskbarPinShortcutLink(const wchar_t* shortcut);
275
276 // Unpins a shortcut from the Windows 7 taskbar. The shortcut must exist and
277 // already be pinned to the taskbar.
278 BASE_EXPORT bool TaskbarUnpinShortcutLink(const wchar_t* shortcut);
279
280 // Copy from_path to to_path recursively and then delete from_path recursively. 229 // Copy from_path to to_path recursively and then delete from_path recursively.
281 // Returns true if all operations succeed. 230 // Returns true if all operations succeed.
282 // This function simulates Move(), but unlike Move() it works across volumes. 231 // This function simulates Move(), but unlike Move() it works across volumes.
283 // This fuction is not transactional. 232 // This fuction is not transactional.
284 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, 233 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path,
285 const FilePath& to_path); 234 const FilePath& to_path);
286 #endif // defined(OS_WIN) 235 #endif // defined(OS_WIN)
287 236
288 // Return true if the given directory is empty 237 // Return true if the given directory is empty
289 BASE_EXPORT bool IsDirectoryEmpty(const FilePath& dir_path); 238 BASE_EXPORT bool IsDirectoryEmpty(const FilePath& dir_path);
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 }; 620 };
672 621
673 // Attempts determine the FileSystemType for |path|. 622 // Attempts determine the FileSystemType for |path|.
674 // Returns false if |path| doesn't exist. 623 // Returns false if |path| doesn't exist.
675 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type); 624 BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type);
676 #endif 625 #endif
677 626
678 } // namespace file_util 627 } // namespace file_util
679 628
680 #endif // BASE_FILE_UTIL_H_ 629 #endif // BASE_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698