Kaydet (Commit) 75e014c3 authored tarafından Andras Timar's avatar Andras Timar

fdo#61514 clean obsolete tools/ filesystem abstraction

Change-Id: I7d1d5eca43d0b0f9a013e31383abc574a7b15f93
üst 79af094f
......@@ -49,10 +49,6 @@ $(eval $(call gb_Library_add_exception_objects,tl,\
tools/source/datetime/tdate \
tools/source/datetime/ttime \
tools/source/debug/debug \
tools/source/fsys/comdep \
tools/source/fsys/dirent \
tools/source/fsys/fstat \
tools/source/fsys/tdir \
tools/source/fsys/tempfile \
tools/source/fsys/urlobj \
tools/source/fsys/wldcrd \
......
......@@ -36,7 +36,6 @@ $(eval $(call gb_Package_add_file,tools_inc,inc/tools/extendapplicationenvironme
$(eval $(call gb_Package_add_file,tools_inc,inc/tools/fldunit.hxx,tools/fldunit.hxx))
$(eval $(call gb_Package_add_file,tools_inc,inc/tools/fontenum.hxx,tools/fontenum.hxx))
$(eval $(call gb_Package_add_file,tools_inc,inc/tools/fract.hxx,tools/fract.hxx))
$(eval $(call gb_Package_add_file,tools_inc,inc/tools/fsys.hxx,tools/fsys.hxx))
$(eval $(call gb_Package_add_file,tools_inc,inc/tools/gen.hxx,tools/gen.hxx))
$(eval $(call gb_Package_add_file,tools_inc,inc/tools/getprocessworkingdir.hxx,tools/getprocessworkingdir.hxx))
$(eval $(call gb_Package_add_file,tools_inc,inc/tools/globname.hxx,tools/globname.hxx))
......
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "comdep.hxx"
#include <tools/debug.hxx>
#include <tools/fsys.hxx>
DBG_NAMEEX( DirEntry )
#if defined UNX
#include "unx.cxx"
#elif defined WNT
#include "wntmsc.cxx"
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef _COMDEP_HXX
#define _COMDEP_HXX
#include <tools/fsys.hxx>
#define ACCESSDELIM(e) ( ( e == FSYS_STYLE_NTFS ) ? "\\" : "/" )
#define ACCESSDELIM_C(e)(char)\
( ( e == FSYS_STYLE_NTFS ) ? '\\' : '/' )
#define SEARCHDELIM(e) ( (e == FSYS_STYLE_BSD) ? ":" : ";" )
#define ACTPARENT(e) ".."
#define ACTCURRENT(e) "."
#if defined UNX
#include "unx.hxx"
#elif defined WNT
#include "wntmsc.hxx"
#endif
#ifndef LINUX
DIR *opendir( const char* pPfad );
dirent *readdir( DIR *pDir );
int closedir( DIR *pDir );
char *volumeid( const char* pPfad );
#endif
struct DirReader_Impl
{
Dir* pDir;
DIR* pDosDir;
dirent* pDosEntry;
DirEntry* pParent;
String aPath;
rtl::OString aBypass;
sal_Bool bReady;
sal_Bool bInUse;
DirReader_Impl( Dir &rDir )
: pDir( &rDir ),
pDosEntry( 0 ),
pParent( 0 ),
aPath(rDir.GetFull()),
bReady ( sal_False ),
bInUse( sal_False )
{
// only use the String from Member-Var
#if defined(UNX) // for further explanation see DirReader_Impl::Read() in unx.cxx
pDosDir = NULL;
#else
aBypass = rtl::OUStringToOString(aPath, osl_getThreadTextEncoding());
pDosDir = opendir( aBypass.getStr() );
#endif
// Determine parents for new DirEntries
pParent = pDir->GetFlag() == FSYS_FLAG_NORMAL ||
pDir->GetFlag() == FSYS_FLAG_ABSROOT
? pDir
: pDir->GetParent();
}
~DirReader_Impl()
{ if( pDosDir ) closedir( pDosDir ); }
// Init and Read are system-independent
sal_uInt16 Init(); ///< Initializes (and if necessary) reads devices
sal_uInt16 Read(); ///< Reads one entry and appends it if ok
};
#if defined WNT
sal_Bool IsRedirectable_Impl( const rtl::OString &rPath );
#else
#define IsRedirectable_Impl( rPath ) sal_True
#endif
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifdef UNX
#include <errno.h>
#endif
#include <limits.h>
#include <string.h>
#include "comdep.hxx"
#include <tools/fsys.hxx>
FileStat::FileStat( const DirEntry& rDirEntry, FSysAccess nAccess )
: // don't use Default-Ctors!
aDateCreated( sal_uIntPtr(0) ),
aTimeCreated( sal_uIntPtr(0) ),
aDateModified( sal_uIntPtr(0) ),
aTimeModified( sal_uIntPtr(0) ),
aDateAccessed( sal_uIntPtr(0) ),
aTimeAccessed( sal_uIntPtr(0) )
{
sal_Bool bCached = FSYS_ACCESS_CACHED == (nAccess & FSYS_ACCESS_CACHED);
sal_Bool bFloppy = FSYS_ACCESS_FLOPPY == (nAccess & FSYS_ACCESS_FLOPPY);
const FileStat *pStatFromDir = bCached ? rDirEntry.ImpGetStat() : 0;
if ( pStatFromDir )
{
nError = pStatFromDir->nError;
nKindFlags = pStatFromDir->nKindFlags;
nSize = pStatFromDir->nSize;
aCreator = pStatFromDir->aCreator;
aType = pStatFromDir->aType;
aDateCreated = pStatFromDir->aDateCreated;
aTimeCreated = pStatFromDir->aTimeCreated;
aDateModified = pStatFromDir->aDateModified;
aTimeModified = pStatFromDir->aTimeModified;
aDateAccessed = pStatFromDir->aDateAccessed;
aTimeAccessed = pStatFromDir->aTimeAccessed;
}
else
Update( rDirEntry, bFloppy );
}
sal_Bool FileStat::IsKind( DirEntryKind nKind ) const
{
sal_Bool bRet = ( ( nKind == FSYS_KIND_UNKNOWN ) &&
( nKindFlags == FSYS_KIND_UNKNOWN ) ) ||
( ( nKindFlags & nKind ) == nKind );
return bRet;
}
sal_Bool FileStat::GetReadOnlyFlag( const DirEntry &rEntry )
{
rtl::OString aFPath(rtl::OUStringToOString(rEntry.GetFull(), osl_getThreadTextEncoding()));
#if defined WNT
DWORD nRes = GetFileAttributes( (LPCTSTR) aFPath.getStr() );
return ULONG_MAX != nRes &&
( FILE_ATTRIBUTE_READONLY & nRes ) == FILE_ATTRIBUTE_READONLY;
#elif defined UNX
/* could we stat the object? */
struct stat aBuf;
if (stat(aFPath.getStr(), &aBuf))
return sal_False;
/* jupp, is writable for user? */
return((aBuf.st_mode & S_IWUSR) != S_IWUSR);
#else
return sal_False;
#endif
}
sal_uIntPtr FileStat::SetReadOnlyFlag( const DirEntry &rEntry, sal_Bool bRO )
{
rtl::OString aFPath(rtl::OUStringToOString(rEntry.GetFull(), osl_getThreadTextEncoding()));
#if defined WNT
DWORD nRes = GetFileAttributes( (LPCTSTR) aFPath.getStr() );
if ( ULONG_MAX != nRes )
nRes = SetFileAttributes( (LPCTSTR) aFPath.getStr(),
( nRes & ~FILE_ATTRIBUTE_READONLY ) |
( bRO ? FILE_ATTRIBUTE_READONLY : 0 ) );
return ( ULONG_MAX == nRes ) ? ERRCODE_IO_UNKNOWN : 0;
#elif defined UNX
/* first, stat the object to get permissions */
struct stat aBuf;
if (stat(aFPath.getStr(), &aBuf))
return ERRCODE_IO_NOTEXISTS;
/* set or clear write bit for user */
mode_t nMode;
if (bRO)
{
nMode = aBuf.st_mode & ~(S_IWUSR | S_IWGRP | S_IWOTH);
}
else
nMode = aBuf.st_mode | S_IWUSR;
/* change it on fs */
if (chmod(aFPath.getStr(), nMode))
{
switch (errno)
{
case EPERM :
case EROFS :
return ERRCODE_IO_ACCESSDENIED;
default :
return ERRCODE_IO_NOTEXISTS;
}
}
else
return ERRCODE_NONE;
#else
return ERRCODE_IO_NOTSUPPORTED;
#endif
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
......@@ -18,7 +18,6 @@
*/
#include <tools/tempfile.hxx>
#include "comdep.hxx"
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
......
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef _unx_hxx
#define _unx_hxx
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <dirent.h>
#include <unistd.h>
#define _mkdir(p) mkdir(p, 0777)
#define _rmdir rmdir
#define _chdir chdir
#define _unlink unlink
#define _getcwd getcwd
#define _access access
#define DEFSTYLE FSYS_STYLE_BSD
#define CMP_LOWER(s) (s)
#define LOWER(aString) (aString.Lower())
#include <time.h>
inline Time Unx2Time( time_t nTime )
{
tm atm;
tm *pTime;
pTime = localtime_r( &nTime, &atm );
return Time( pTime->tm_hour,
pTime->tm_min,
pTime->tm_sec );
}
inline Date Unx2Date( time_t nDate )
{
tm atm;
tm *pTime;
pTime = localtime_r( &nDate, &atm );
return Date( pTime->tm_mday,
pTime->tm_mon + 1,
pTime->tm_year + 1900 );
}
inline void Unx2DateAndTime( time_t nDate, Time& rTime, Date& rDate )
{
tm atm;
tm *pTime;
pTime = localtime_r( &nDate, &atm );
rTime = Time( pTime->tm_hour, pTime->tm_min, pTime->tm_sec );
rDate = Date( pTime->tm_mday, pTime->tm_mon + 1, pTime->tm_year + 1900 );
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef _dosmsc_hxx
#define _dosmsc_hxx
#include <string.h>
#ifndef ICC
#include <io.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <direct.h>
#include <windows.h>
#include <tools/solar.h>
#include <rtl/strbuf.hxx>
#define DOS_DIRECT _A_SUBDIR
#define DOS_VOLUMEID 0x08
#ifndef S_IFBLK
#define S_IFBLK 0x6000
#endif
#define dirent _WIN32_FIND_DATAA
#define d_name cFileName
#define d_type dwFileAttributes
typedef struct
{
_WIN32_FIND_DATAA aDirEnt;
HANDLE h;
const char *p;
} DIR;
#define DEFSTYLE FSYS_STYLE_NTFS
#define MKDIR( p ) mkdir( p )
#define CMP_LOWER(s) ( s.toAsciiLowerCase() )
inline sal_Bool DRIVE_EXISTS(char c)
{
rtl::OStringBuffer aDriveRoot;
aDriveRoot.append(c);
aDriveRoot.append(":\\");
return GetDriveType( aDriveRoot.getStr() ) > 1;
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment