summaryrefslogtreecommitdiffstats
path: root/chromium/base/files/file.cc
blob: 4902f15a2ff02744e44699317565797ebf0c05b3 (plain)
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
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/files/file.h"

// TODO(rvargas): remove this (needed for kInvalidPlatformFileValue).
#include "base/platform_file.h"

namespace base {

File::Info::Info()
    : size(0),
      is_directory(false),
      is_symbolic_link(false) {
}

File::Info::~Info() {
}

File::File()
    : file_(kInvalidPlatformFileValue),
      error_(FILE_OK),
      created_(false),
      async_(false) {
}

#if !defined(OS_NACL)
File::File(const FilePath& name, uint32 flags)
    : file_(kInvalidPlatformFileValue),
      error_(FILE_OK),
      created_(false),
      async_(false) {
  if (name.ReferencesParent()) {
    error_ = FILE_ERROR_ACCESS_DENIED;
    return;
  }
  CreateBaseFileUnsafe(name, flags);
}
#endif

File::File(RValue other)
    : file_(other.object->TakePlatformFile()),
      error_(other.object->error()),
      created_(other.object->created()),
      async_(other.object->async_) {
}

File::~File() {
  Close();
}

File& File::operator=(RValue other) {
  if (this != other.object) {
    Close();
    SetPlatformFile(other.object->TakePlatformFile());
    error_ = other.object->error();
    created_ = other.object->created();
    async_ = other.object->async_;
  }
  return *this;
}

}  // namespace base