nsFileSpecBeOS.cpp revision 677833bc953b6cb418c701facbdcf4aa18d6c44e
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// This file is included by nsFileSpec.cpp, and includes the Unix-specific
// implementations.
#include <errno.h>
#include <dirent.h>
#include <unistd.h>
#include <stdlib.h>
#include <limits.h>
#include "nsError.h"
#include "prio.h" /* for PR_Rename */
// BeOS specific headers
#include <Entry.h>
#include <Path.h>
#include <Volume.h>
//----------------------------------------------------------------------------------------
// Canonify, make absolute, and check whether directories exist
//----------------------------------------------------------------------------------------
{
return;
if (inMakeDirs)
{
}
char buffer[MAXPATHLEN];
errno = 0;
*buffer = '\0';
BPath p;
e.GetPath(&p);
} // nsFileSpecHelpers::Canonify
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
} // nsFileSpec::SetLeafName
//----------------------------------------------------------------------------------------
char* nsFileSpec::GetLeafName() const
//----------------------------------------------------------------------------------------
{
} // nsFileSpec::GetLeafName
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
} // nsFileSpec::Exists
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
else
outStamp = 0;
} // nsFileSpec::GetModDate
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
return 0;
} // nsFileSpec::GetFileSize
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
} // nsFileSpec::IsFile
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
} // nsFileSpec::IsDirectory
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
char *leafname = GetLeafName();
{
{
}
}
return hidden;
} // nsFileSpec::IsHidden
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
return PR_TRUE;
return PR_FALSE;
} // nsFileSpec::IsSymlink
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
char resolvedPath[MAXPATHLEN];
if (0 < charCount)
{
if (MAXPATHLEN > charCount)
/* if it's not an absolute path,
replace the leaf with what got resolved */
if (resolvedPath[0] != '/') {
}
else {
mPath = (char*)resolvedPath;
}
BPath p;
const char* canonicalPath = p.Path();
mPath = (char*)canonicalPath;
else
return NS_ERROR_FAILURE;
}
return NS_OK;
} // nsFileSpec::ResolveSymlink
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
if (cp++)
} // nsFileSpec::GetParent
//----------------------------------------------------------------------------------------
void nsFileSpec::operator += (const char* inRelativePath)
//----------------------------------------------------------------------------------------
{
return;
if (endChar == '/')
mPath += "x";
else
mPath += "/x";
} // nsFileSpec::operator +=
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
// Note that mPath is canonical!
return;
} // nsFileSpec::CreateDirectory
//----------------------------------------------------------------------------------------
// To check if this worked, call Exists() afterwards, see?
//----------------------------------------------------------------------------------------
{
if (IsDirectory())
{
if (inRecursive)
{
{
}
}
}
} // nsFileSpec::Delete
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
if (IsDirectory())
{
{
}
{
if (child.IsDirectory())
{
tmpDirSpec += leafname;
}
else
{
}
}
}
{
{
}
}
} // nsFileSpec::RecursiveCopy
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
if(!rv)
return NS_OK ;
else
return NS_ERROR_FAILURE ;
} // nsFileSpec::Truncate
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
// This function should not be used to move a file on disk.
return NS_FILE_FAILURE;
{
// Could not rename, set back to the original.
return NS_FILE_FAILURE;
}
return NS_OK;
} // nsFileSpec::Rename
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
int stat_result = -1;
char buf [1024];
return -1;
if (!ifp)
{
return -1;
}
if (!ofp)
{
return -1;
}
{
while (rbytes > 0)
{
{
return -1;
}
}
}
if (stat_result == 0)
return 0;
} // nsFileSpec::Rename
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
// We can only copy into a directory, and (for now) can not copy entire directories
{
char *leafname = GetLeafName();
destPath += "/";
}
return result;
} // nsFileSpec::CopyToDir
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
// We can only copy into a directory, and (for now) can not copy entire directories
{
char *leafname = GetLeafName();
destPath += "/";
{
// cast to fix const-ness
*this = inNewParentDirectory + GetLeafName();
}
}
return result;
}
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
{
}
return result;
} // nsFileSpec::Execute
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
char curdir [MAXPATHLEN];
{
if (!curdir)
return ULONGLONG_MAX; /* hope for the best as we did in cheddar */
}
else
return ULONGLONG_MAX; /* hope for the best as we did in cheddar */
#ifdef DEBUG_DISK_SPACE
#endif
return v.FreeBytes();
} // nsFileSpec::GetDiskSpace()
//========================================================================================
// nsDirectoryIterator
//========================================================================================
//----------------------------------------------------------------------------------------
const nsFileSpec& inDirectory
//----------------------------------------------------------------------------------------
{
++(*this);
} // nsDirectoryIterator::nsDirectoryIterator
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
{
if (mDir)
} // nsDirectoryIterator::nsDirectoryIterator
//----------------------------------------------------------------------------------------
nsDirectoryIterator& nsDirectoryIterator::operator ++ ()
//----------------------------------------------------------------------------------------
{
if (!mDir)
return *this;
char* dot = ".";
char* dotdot = "..";
if (entry)
{
mCurrent = mStarting; // restore mCurrent to be the starting directory. ResolveSymlink() may have taken us to another directory
if (mResoveSymLinks)
{
}
}
return *this;
} // nsDirectoryIterator::operator ++
//----------------------------------------------------------------------------------------
nsDirectoryIterator& nsDirectoryIterator::operator -- ()
//----------------------------------------------------------------------------------------
{
return ++(*this); // can't do it backwards.
} // nsDirectoryIterator::operator --