1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: global.cxx,v $
10 * $Revision: 1.14.8.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include <osl/process.h>
31 #ifndef _RTL_OSTRINGBUFFER_HXX_
32 #include <rtl/strbuf.hxx>
34 #include <rtl/ustring.hxx>
35 #include <osl/thread.h>
36 #include <osl/file.hxx>
40 #if defined(SAL_W32) || defined(SAL_OS2)
51 #include <codemaker/global.hxx>
56 #define SEPARATOR '\\'
59 using namespace ::rtl
;
60 using namespace ::osl
;
62 const OString
inGlobalSet(const OUString
& rValue
)
64 OString
sValue( OUStringToOString(rValue
, RTL_TEXTENCODING_UTF8
) );
65 static StringSet aGlobalMap
;
66 StringSet::iterator iter
= aGlobalMap
.find( sValue
);
67 if( iter
!= aGlobalMap
.end() )
69 return *(aGlobalMap
.insert( sValue
).first
);
72 static sal_Bool
isFileUrl(const OString
& fileName
)
74 if (fileName
.indexOf("file://") == 0 )
79 OUString
convertToFileUrl(const OString
& fileName
)
81 if ( isFileUrl(fileName
) )
83 return OStringToOUString(fileName
, osl_getThreadTextEncoding());
86 OUString uUrlFileName
;
87 OUString
uFileName(fileName
.getStr(), fileName
.getLength(), osl_getThreadTextEncoding());
88 if ( fileName
.indexOf('.') == 0 || fileName
.indexOf(SEPARATOR
) < 0 )
91 if (osl_getProcessWorkingDir(&uWorkingDir
.pData
) != osl_Process_E_None
) {
94 if (FileBase::getAbsoluteFileURL(uWorkingDir
, uFileName
, uUrlFileName
)
101 if (FileBase::getFileURLFromSystemPath(uFileName
, uUrlFileName
)
111 //*************************************************************************
113 //*************************************************************************
114 FileStream::FileStream()
118 FileStream::~FileStream()
127 sal_Bool
FileStream::isValid()
135 void FileStream::open(const OString
& name
, FileAccessMode mode
)
137 if ( name
.getLength() > 0 )
140 m_pFile
= fopen(m_name
, checkAccessMode(mode
));
144 void FileStream::close()
155 const sal_Char
* FileStream::checkAccessMode(FileAccessMode mode
)
165 case FAM_READWRITE_EXIST
: