The Pedigree Project  0.1
Symlink.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef SYMLINK_H
21 #define SYMLINK_H
22 
23 #include "File.h"
24 #include "pedigree/kernel/Log.h"
25 #include "pedigree/kernel/compiler.h"
26 #include "pedigree/kernel/processor/types.h"
27 #include "pedigree/kernel/time/Time.h"
28 #include "pedigree/kernel/utilities/String.h"
29 
32 {
33  friend class Filesystem;
34 
35  public:
37  static Symlink *fromFile(File *pF)
38  {
39  if (!pF->isSymlink())
40  FATAL("Casting non-symlink File to Symlink!");
41  return reinterpret_cast<Symlink *>(pF);
42  }
43 
45  Symlink();
46 
48  Symlink(const Symlink &file);
49 
50  private:
51  Symlink &operator=(const Symlink &);
52 
53  public:
55  Symlink(
56  const String &name, Time::Timestamp accessedTime,
57  Time::Timestamp modifiedTime, Time::Timestamp creationTime,
58  uintptr_t inode, class Filesystem *pFs, size_t size, File *pParent);
60  virtual ~Symlink();
61 
63  virtual bool isSymlink()
64  {
65  return true;
66  }
67 
70  int followLink(char *pBuffer, size_t bufLen);
71 
73  File *followLink();
74 
75  protected:
76  File *m_pCachedSymlink;
77 
78  String m_sTarget;
79 
81  void initialise(bool bForce = false);
82 
85  virtual bool isBytewise() const;
86 };
87 
88 #endif
virtual bool isBytewise() const
Definition: File.cc:577
void operator=(const Filesystem &)
Definition: String.h:49
virtual bool isSymlink()
Definition: File.cc:431
virtual bool initialise(Disk *pDisk)=0
#define FATAL(text)
Definition: Log.h:89
Definition: File.h:66