File: delete_after_reboot_helper.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (78 lines) | stat: -rw-r--r-- 3,349 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright 2009 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// This file declares helper methods used to schedule files for deletion
// on next reboot.

#ifndef CHROME_INSTALLER_UTIL_DELETE_AFTER_REBOOT_HELPER_H_
#define CHROME_INSTALLER_UTIL_DELETE_AFTER_REBOOT_HELPER_H_

#include <windows.h>

#include <stddef.h>

#include <string>
#include <vector>

namespace base {
class FilePath;
}

// Used by the unit tests.
extern const wchar_t kSessionManagerKey[];
extern const wchar_t kPendingFileRenameOps[];

typedef std::pair<std::wstring, std::wstring> PendingMove;

// Attempts to schedule only the item at path for deletion.
bool ScheduleFileSystemEntityForDeletion(const base::FilePath& path);

// Attempts to recursively schedule the directory for deletion.
bool ScheduleDirectoryForDeletion(const base::FilePath& dir_name);

// Removes all pending moves that are registered for |directory| and all
// elements contained in |directory|.
bool RemoveFromMovesPendingReboot(const base::FilePath& directory);

// Retrieves the list of pending renames from the registry and returns a vector
// containing pairs of strings that represent the operations. If the list
// contains only deletes then every other element will be an empty string
// as per http://msdn.microsoft.com/en-us/library/aa365240(VS.85).aspx.
HRESULT GetPendingMovesValue(std::vector<PendingMove>* pending_moves);

// This returns true if |short_form_needle| is contained in |reg_path| where
// |short_form_needle| is a file system path that has been shortened by
// GetShortPathName and |reg_path| is a path stored in the
// PendingFileRenameOperations key.
bool MatchPendingDeletePath(const base::FilePath& short_form_needle,
                            const base::FilePath& reg_path);

// Converts the strings found in |buffer| to a list of PendingMoves that is
// returned in |value|.
// |buffer| points to a series of pairs of null-terminated wchar_t strings
// followed by a terminating null character.
// |byte_count| is the length of |buffer| in bytes.
// |value| is a pointer to an empty vector of PendingMoves (string pairs).
// On success, this vector contains all of the string pairs extracted from
// |buffer|.
// Returns S_OK on success, E_INVALIDARG if buffer does not meet the above
// specification.
HRESULT MultiSZBytesToStringArray(const char* buffer,
                                  size_t byte_count,
                                  std::vector<PendingMove>* value);

// The inverse of MultiSZBytesToStringArray, this function converts a list
// of string pairs into a byte array format suitable for writing to the
// kPendingFileRenameOps registry value. It concatenates the strings and
// appends an additional terminating null character.
void StringArrayToMultiSZBytes(const std::vector<PendingMove>& strings,
                               std::vector<char>* buffer);

// A helper function for the win32 GetShortPathName that more conveniently
// returns a FilePath. Note that if |path| is not present on the file system
// then GetShortPathName will return |path| unchanged, unlike the win32
// GetShortPathName which will return an error.
base::FilePath GetShortPathName(const base::FilePath& path);

#endif  // CHROME_INSTALLER_UTIL_DELETE_AFTER_REBOOT_HELPER_H_