inode - type = that.type; contents = that.contents; } TRACE...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <cassert> #include <iostream> using namespace std; #include "trace.h" #include "inode.h" int inode::next_inode_nr = 1; inode::inode(inode_t init_type): inode_nr (next_inode_nr++), type (init_type) { switch (type) { case DIR_INODE: contents.dirents = new directory(); break; case FILE_INODE: contents.data = new wordvec(); break; } TRACE ('i', "inode " << inode_nr << ", type = " << type); }; // // copy ctor - // Make a copy of a given inode. This should not be used in // your program if you can avoid it, since it is expensive. // Here, we can leverage operator=. // *this = that; } // // operator= - // Assignment operator. Copy an inode. Make a copy of a // given inode. This should not be used in your program if // you can avoid it, since it is expensive. // inode_nr = that.inode_nr;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: type = that.type; contents = that.contents; } TRACE ('i', &quot;inode &quot; &lt;&lt; inode_nr &lt;&lt; &quot;, type = &quot; &lt;&lt; type); return *this; } int inode::get_inode_nr() { TRACE ('i', &quot;inode = &quot; &lt;&lt; inode_nr); return inode_nr; } int inode::size() { int size = 0; TRACE ('i', &quot;size = &quot; &lt;&lt; size); return size; } wordvec &amp;inode::readfile() { TRACE ('i', *contents.data); assert (type == FILE_INODE); return *contents.data; } void inode::writefile (const wordvec &amp;words) { TRACE ('i', words); assert (type == FILE_INODE); } void inode::remove (const string &amp;filename) { TRACE ('i', filename); assert (type == DIR_INODE); } inode_state::inode_state(): root (NULL), cwd (NULL), prompt (&quot;%&quot;) { TRACE ('i', &quot;root = &quot; &lt;&lt; (void*) root &lt;&lt; &quot;, cwd = &quot; &lt;&lt; (void*) cwd &lt;&lt; &quot;, prompt = &quot; &lt;&lt; prompt); } RCSC(inode_cc, &quot;$Id: inode.cc,v 1.23 2009-01-20 15:57:02-08 - - $&quot;)...
View Full Document

Page1 / 2

inode - type = that.type; contents = that.contents; } TRACE...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online