summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx1
-rw-r--r--bridges/source/cpp_uno/gcc3_macosx_powerpc/uno2cpp.cxx3
-rw-r--r--bridges/source/cpp_uno/gcc3_os2_intel/cpp2uno.cxx3
-rw-r--r--bridges/source/cpp_uno/mingw_intel/call.s21
-rw-r--r--bridges/test/com/sun/star/lib/TestBed.java4
-rw-r--r--bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug107753_Test.java14
-rw-r--r--bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug108825_Test.java2
-rw-r--r--bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug110892_Test.java2
-rw-r--r--bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug111153_Test.java2
-rw-r--r--bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug51323_Test.java2
-rw-r--r--bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug92174_Test.java2
-rw-r--r--bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug97697_Test.java2
-rw-r--r--bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug98508_Test.java2
-rwxr-xr-xbridges/test/com/sun/star/lib/uno/bridges/java_remote/MethodIdTest.java2
-rw-r--r--bridges/test/com/sun/star/lib/uno/bridges/java_remote/PolyStructTest.java2
-rw-r--r--bridges/test/com/sun/star/lib/uno/bridges/java_remote/StopMessageDispatcherTest.java2
-rw-r--r--bridges/test/java_uno/acquire/TestAcquire.java4
-rw-r--r--bridges/test/java_uno/any/TestRemote.java2
-rw-r--r--bridges/test/java_uno/equals/TestEquals.java40
-rw-r--r--bridges/test/java_uno/nativethreadpool/Relay.java2
-rw-r--r--bridges/test/testclient.java4
-rw-r--r--cli_ure/version/version.txt24
-rwxr-xr-xcpputools/source/regcomplazy/regcomplazy.cxx2
-rw-r--r--io/inc/makefile.mk6
-rw-r--r--io/source/TextInputStream/makefile.mk2
-rw-r--r--io/source/TextOutputStream/makefile.mk2
-rw-r--r--io/source/acceptor/makefile.mk3
-rw-r--r--io/source/connector/makefile.mk2
-rw-r--r--io/source/stm/makefile.mk4
-rw-r--r--io/test/makefile.mk2
-rw-r--r--io/test/stm/makefile.mk2
-rw-r--r--javaunohelper/com/sun/star/comp/helper/Bootstrap.java20
-rw-r--r--javaunohelper/com/sun/star/comp/helper/ComponentContext.java12
-rw-r--r--javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java2
-rw-r--r--javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader.java4
-rw-r--r--javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java2
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/Factory.java2
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java2
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java2
-rw-r--r--javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java94
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java4
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java2
-rw-r--r--javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java10
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java6
-rw-r--r--javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java8
-rw-r--r--jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java8
-rw-r--r--jurt/com/sun/star/comp/loader/FactoryHelper.java4
-rw-r--r--jurt/com/sun/star/comp/loader/JavaLoader.java2
-rw-r--r--jurt/com/sun/star/comp/servicemanager/ServiceManager.java18
-rw-r--r--jurt/com/sun/star/comp/urlresolver/UrlResolver.java4
-rw-r--r--jurt/com/sun/star/uno/WeakReference.java4
-rw-r--r--jurt/demo/com/sun/star/demo/DemoServer.java4
-rw-r--r--jurt/demo/com/sun/star/demo/TestOffice.java18
-rw-r--r--jurt/test/com/sun/star/comp/bridgefactory/BridgeFactory_Test.java4
-rw-r--r--jurt/test/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge_Test.java6
-rw-r--r--jurt/workbench/com/sun/star/comp/urlresolver/UrlResolver_Test.java6
-rw-r--r--jvmfwk/distributions/OpenOfficeorg/javavendors_freebsd.xml4
-rw-r--r--jvmfwk/distributions/OpenOfficeorg/javavendors_os2.xml4
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx6
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/sunjre.cxx2
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx2
-rw-r--r--jvmfwk/plugins/sunmajor/pluginlib/util.cxx23
-rw-r--r--offapi/com/sun/star/chart2/XDataSeries.idl20
-rw-r--r--offapi/com/sun/star/chart2/XDefaultSizeTransmitter.idl67
-rw-r--r--offapi/com/sun/star/chart2/makefile.mk1
-rw-r--r--offapi/com/sun/star/document/MediaDescriptor.idl6
-rw-r--r--offapi/com/sun/star/document/PDFDialog.idl67
-rw-r--r--offapi/com/sun/star/document/makefile.mk3
-rw-r--r--offapi/com/sun/star/drawing/framework/XPane2.idl79
-rw-r--r--offapi/com/sun/star/drawing/framework/makefile.mk1
-rw-r--r--offapi/com/sun/star/embed/Storage.idl13
-rw-r--r--offapi/com/sun/star/modules.idl3
-rw-r--r--offapi/com/sun/star/office/XAnnotation.idl105
-rw-r--r--offapi/com/sun/star/office/XAnnotationAccess.idl75
-rw-r--r--offapi/com/sun/star/office/XAnnotationEnumeration.idl74
-rw-r--r--offapi/com/sun/star/office/makefile.mk51
-rw-r--r--offapi/com/sun/star/security/DocumentSignatureInformation.idl19
-rw-r--r--offapi/com/sun/star/task/DocumentMSPasswordRequest.idl2
-rw-r--r--offapi/com/sun/star/task/DocumentMacroConfirmationRequest2.idl83
-rw-r--r--offapi/com/sun/star/task/XUrlContainer.idl92
-rw-r--r--offapi/com/sun/star/task/makefile.mk4
-rw-r--r--offapi/com/sun/star/text/InContentMetadata.idl81
-rw-r--r--offapi/com/sun/star/text/TextPortion.idl9
-rw-r--r--offapi/com/sun/star/text/makefile.mk1
-rw-r--r--offapi/com/sun/star/text/textfield/MetadataField.idl102
-rw-r--r--offapi/com/sun/star/text/textfield/makefile.mk1
-rw-r--r--offapi/com/sun/star/ucb/URLAuthenticationRequest.idl58
-rw-r--r--offapi/com/sun/star/ucb/XInteractionSupplyAuthentication2.idl79
-rw-r--r--offapi/com/sun/star/ucb/makefile.mk230
-rw-r--r--offapi/prj/build.lst3
-rw-r--r--offapi/util/makefile.mk1
-rw-r--r--offuh/prj/d.lst4
-rw-r--r--pyuno/prj/d.lst1
-rw-r--r--pyuno/source/loader/makefile.mk10
-rw-r--r--pyuno/source/module/makefile.mk8
-rwxr-xr-xpyuno/zipcore/makefile.mk7
-rw-r--r--remotebridges/source/bridge/makefile.mk2
-rwxr-xr-xremotebridges/source/dynamicloader/makefile.mk2
-rw-r--r--remotebridges/source/factory/makefile.mk2
-rw-r--r--remotebridges/source/unourl_resolver/makefile.mk2
-rw-r--r--ridljar/com/sun/star/uno/UnoRuntime.java5
-rw-r--r--ridljar/test/com/sun/star/uno/UnoRuntime_Test.java8
-rw-r--r--sal/inc/rtl/math.h36
-rw-r--r--sal/inc/rtl/math.hxx29
-rw-r--r--sal/inc/sal/types.h9
-rw-r--r--sal/osl/all/makefile.mk6
-rw-r--r--sal/osl/all/readline.c311
-rw-r--r--sal/osl/os2/debug.c47
-rw-r--r--sal/osl/os2/except.c44
-rw-r--r--sal/osl/os2/helpers/debug.h42
-rw-r--r--sal/osl/os2/helpers/dosh.h927
-rw-r--r--sal/osl/os2/helpers/except.h42
-rw-r--r--sal/osl/os2/helpers/setup.h32
-rw-r--r--sal/osl/os2/module.c2
-rw-r--r--sal/osl/os2/process.c10
-rw-r--r--sal/osl/unx/file.cxx4111
-rw-r--r--sal/osl/unx/file_impl.hxx43
-rw-r--r--sal/osl/unx/file_misc.cxx1084
-rw-r--r--sal/osl/unx/file_stat.cxx281
-rw-r--r--sal/osl/unx/file_url.cxx177
-rw-r--r--sal/osl/unx/file_url.h58
-rw-r--r--sal/osl/unx/file_volume.cxx1570
-rw-r--r--sal/osl/unx/makefile.mk12
-rw-r--r--sal/osl/unx/process.c173
-rw-r--r--sal/osl/unx/signal.c92
-rw-r--r--sal/osl/w32/MAKEFILE.MK8
-rw-r--r--sal/osl/w32/diagnose.c5
-rw-r--r--sal/osl/w32/file.cxx4001
-rw-r--r--sal/osl/w32/file_dirvol.cxx1777
-rw-r--r--sal/osl/w32/file_error.c154
-rw-r--r--sal/osl/w32/file_error.h54
-rw-r--r--sal/osl/w32/file_url.cxx1013
-rw-r--r--sal/osl/w32/file_url.h95
-rw-r--r--sal/osl/w32/procimpl.cxx8
-rw-r--r--sal/osl/w32/tempfile.cxx279
-rw-r--r--sal/rtl/source/math.cxx250
-rwxr-xr-xsal/util/sal.map4
-rw-r--r--sal/workben/makefile.mk23
-rw-r--r--sal/workben/t_layer.c314
-rw-r--r--sal/workben/t_readline.c58
-rw-r--r--sal/workben/t_tls.c257
-rw-r--r--sal/workben/t_zip.c183
-rw-r--r--stoc/source/inspect/introspection.cxx46
-rw-r--r--store/source/lockbyte.cxx2
-rw-r--r--store/workben/makefile.mk11
-rw-r--r--unoil/climaker/version.txt6
-rw-r--r--ure/source/makefile.mk2
-rw-r--r--ure/source/uretest/JavaClient.java10
-rw-r--r--xml2cmp/source/xcd/filebuff.cxx4
149 files changed, 10293 insertions, 9246 deletions
diff --git a/bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx b/bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx
index 6141efd7964a..e474dce7268c 100644
--- a/bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_s390x/except.cxx
@@ -33,6 +33,7 @@
#include "precompiled_bridges.hxx"
#include <stdio.h>
+#include <string.h>
#include <dlfcn.h>
#include <cxxabi.h>
#include <hash_map>
diff --git a/bridges/source/cpp_uno/gcc3_macosx_powerpc/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_macosx_powerpc/uno2cpp.cxx
index 0f0fdbf351ca..e3f4d36e3962 100644
--- a/bridges/source/cpp_uno/gcc3_macosx_powerpc/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_macosx_powerpc/uno2cpp.cxx
@@ -110,6 +110,9 @@ static void callVirtualMethod(
/* set up a pointer to the stack parameter area */
__asm__ ( "addi %0,r1,24" : "=r" (p) : /* no inputs */ );
+ // #i94421#, work around compiler error:
+ volatile long * pCopy = p;
+ (void) pCopy; // avoid warning about unused variable
// never called
// if (! pAdjustedThisPtr )CPPU_CURRENT_NAMESPACE::dummy_can_throw_anything("xxx"); // address something
diff --git a/bridges/source/cpp_uno/gcc3_os2_intel/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_os2_intel/cpp2uno.cxx
index d4584227cdc1..d6589b8d86cf 100644
--- a/bridges/source/cpp_uno/gcc3_os2_intel/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_os2_intel/cpp2uno.cxx
@@ -163,7 +163,8 @@ static typelib_TypeClass cpp2uno_call(
(*pThis->getUnoI()->pDispatcher)(
pThis->getUnoI(), pMemberTypeDescr, pUnoReturn, pUnoArgs, &pUnoExc );
#if OSL_DEBUG_LEVEL > 1
- fprintf( stderr, ">cpp2uno_call pUnoExc %x\n", pUnoExc);
+ if (pUnoExc != NULL)
+ fprintf( stderr, ">cpp2uno_call pUnoExc %x\n", pUnoExc);
#endif
// in case an exception occured...
diff --git a/bridges/source/cpp_uno/mingw_intel/call.s b/bridges/source/cpp_uno/mingw_intel/call.s
index b4a9ba031cf5..47327d9a4650 100644
--- a/bridges/source/cpp_uno/mingw_intel/call.s
+++ b/bridges/source/cpp_uno/mingw_intel/call.s
@@ -1,7 +1,6 @@
.text
.globl _privateSnippetExecutorGeneral
- .type _privateSnippetExecutorGeneral,@function
_privateSnippetExecutorGeneral:
.LFBg:
movl %esp,%ecx
@@ -19,10 +18,9 @@ _privateSnippetExecutorGeneral:
leave
ret
.LFEg:
- .size _privateSnippetExecutorGeneral,.-_privateSnippetExecutorGeneral
+ .long .-_privateSnippetExecutorGeneral
.globl _privateSnippetExecutorVoid
- .type _privateSnippetExecutorVoid,@function
_privateSnippetExecutorVoid:
.LFBv:
movl %esp,%ecx
@@ -38,10 +36,9 @@ _privateSnippetExecutorVoid:
leave
ret
.LFEv:
- .size _privateSnippetExecutorVoid,.-_privateSnippetExecutorVoid
+ .long .-_privateSnippetExecutorVoid
.globl _privateSnippetExecutorHyper
- .type _privateSnippetExecutorHyper,@function
_privateSnippetExecutorHyper:
.LFBh:
movl %esp,%ecx
@@ -60,10 +57,9 @@ _privateSnippetExecutorHyper:
leave
ret
.LFEh:
- .size _privateSnippetExecutorHyper,.-_privateSnippetExecutorHyper
+ .long .-_privateSnippetExecutorHyper
.globl _privateSnippetExecutorFloat
- .type _privateSnippetExecutorFloat,@function
_privateSnippetExecutorFloat:
.LFBf:
movl %esp,%ecx
@@ -81,10 +77,9 @@ _privateSnippetExecutorFloat:
leave
ret
.LFEf:
- .size _privateSnippetExecutorFloat,.-_privateSnippetExecutorFloat
+ .long .-_privateSnippetExecutorFloat
.globl _privateSnippetExecutorDouble
- .type _privateSnippetExecutorDouble,@function
_privateSnippetExecutorDouble:
.LFBd:
movl %esp,%ecx
@@ -102,10 +97,9 @@ _privateSnippetExecutorDouble:
leave
ret
.LFEd:
- .size _privateSnippetExecutorDouble,.-_privateSnippetExecutorDouble
+ .long .-_privateSnippetExecutorDouble
.globl _privateSnippetExecutorClass
- .type _privateSnippetExecutorClass,@function
_privateSnippetExecutorClass:
.LFBc:
movl %esp,%ecx
@@ -123,9 +117,9 @@ _privateSnippetExecutorClass:
leave
ret $4
.LFEc:
- .size _privateSnippetExecutorClass,.-_privateSnippetExecutorClass
+ .long .-_privateSnippetExecutorClass
- .section .eh_frame,"a",@progbits
+ .section .eh_frame,"dr"
.Lframe1:
.long .LECIE1-.LSCIE1 # length
.LSCIE1:
@@ -265,4 +259,3 @@ _privateSnippetExecutorClass:
.uleb128 5
.align 4
.LEFDEc:
- .section .note.GNU-stack,"",@progbits
diff --git a/bridges/test/com/sun/star/lib/TestBed.java b/bridges/test/com/sun/star/lib/TestBed.java
index 7242b56438f0..5e2c5e7859c8 100644
--- a/bridges/test/com/sun/star/lib/TestBed.java
+++ b/bridges/test/com/sun/star/lib/TestBed.java
@@ -130,7 +130,7 @@ public final class TestBed {
throws com.sun.star.uno.Exception
{
XConnector connector = Connector.create(context);
- XBridgeFactory factory = (XBridgeFactory) UnoRuntime.queryInterface(
+ XBridgeFactory factory = UnoRuntime.queryInterface(
XBridgeFactory.class,
context.getServiceManager().createInstanceWithContext(
"com.sun.star.bridge.BridgeFactory", context));
@@ -169,7 +169,7 @@ public final class TestBed {
= Bootstrap.createInitialComponentContext(null);
XAcceptor acceptor = Acceptor.create(context);
XBridgeFactory factory
- = (XBridgeFactory) UnoRuntime.queryInterface(
+ = UnoRuntime.queryInterface(
XBridgeFactory.class,
context.getServiceManager().createInstanceWithContext(
"com.sun.star.bridge.BridgeFactory", context));
diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug107753_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug107753_Test.java
index a2c4122d3017..2c7e314afc82 100644
--- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug107753_Test.java
+++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug107753_Test.java
@@ -68,22 +68,19 @@ public final class Bug107753_Test extends ComplexTestCase {
protected boolean run(XComponentContext context) throws Throwable {
boolean success = true;
- XTransport transport = (XTransport) UnoRuntime.queryInterface(
+ XTransport transport = UnoRuntime.queryInterface(
XTransport.class, getBridge(context).getInstance("Transport"));
Object obj1a = new XType1() {};
- XType1 obj1b = (XType1) UnoRuntime.queryInterface(XType1.class,
- obj1a);
+ XType1 obj1b = UnoRuntime.queryInterface(XType1.class, obj1a);
success &= test("obj1a == obj1b", obj1a == obj1b);
Object obj2a = new XType2() {};
- XType2 obj2b = (XType2) UnoRuntime.queryInterface(XType2.class,
- obj2a);
+ XType2 obj2b = UnoRuntime.queryInterface(XType2.class, obj2a);
success &= test("obj2a == obj2b", obj2a == obj2b);
Object obj3a = transport.getType1();
- XType1 obj3b = (XType1) UnoRuntime.queryInterface(XType1.class,
- obj3a);
+ XType1 obj3b = UnoRuntime.queryInterface(XType1.class, obj3a);
success &= test(
"obj3a != obj3b; only meaningful as long as different proxy"
+ " instances are used for different UNO interfaces of one UNO"
@@ -91,8 +88,7 @@ public final class Bug107753_Test extends ComplexTestCase {
obj3a != obj3b);
Object obj4a = transport.getType2();
- XType2 obj4b = (XType2) UnoRuntime.queryInterface(XType2.class,
- obj4a);
+ XType2 obj4b = UnoRuntime.queryInterface(XType2.class, obj4a);
success &= test(
"obj4a != obj4b; only meaningful as long as different proxy"
+ " instances are used for different UNO interfaces of one UNO"
diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug108825_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug108825_Test.java
index 6e9d97f7034d..0585e1c8f650 100644
--- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug108825_Test.java
+++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug108825_Test.java
@@ -68,7 +68,7 @@ public final class Bug108825_Test extends ComplexTestCase {
}
protected boolean run(XComponentContext context) throws Throwable {
- XTest test = (XTest) UnoRuntime.queryInterface(
+ XTest test = UnoRuntime.queryInterface(
XTest.class, getBridge(context).getInstance("Test"));
// Send the XObject that is held on the server side amidst two
// dummies that are not held on the server side; then wait for the
diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug110892_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug110892_Test.java
index 76bd9d37a10c..1a537895b0ed 100644
--- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug110892_Test.java
+++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug110892_Test.java
@@ -71,7 +71,7 @@ public final class Bug110892_Test extends ComplexTestCase {
}
protected boolean run(XComponentContext context) throws Throwable {
- XTest test = (XTest) UnoRuntime.queryInterface(
+ XTest test = UnoRuntime.queryInterface(
XTest.class, getBridge(context).getInstance("Test"));
test.start(new ClientObject());
synchronized (lock) {
diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug111153_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug111153_Test.java
index d1f09509d9a3..40eccdba2cc6 100644
--- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug111153_Test.java
+++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug111153_Test.java
@@ -63,7 +63,7 @@ public final class Bug111153_Test extends ComplexTestCase {
}
protected boolean run(XComponentContext context) throws Throwable {
- XTransport t = (XTransport) UnoRuntime.queryInterface(
+ XTransport t = UnoRuntime.queryInterface(
XTransport.class, getBridge(context).getInstance("Transport"));
XDerived d = new XDerived() {};
t.setDerived(d);
diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug51323_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug51323_Test.java
index 32bfe9d832a3..247bf65ba185 100644
--- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug51323_Test.java
+++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug51323_Test.java
@@ -67,7 +67,7 @@ public final class Bug51323_Test extends ComplexTestCase {
protected boolean run(XComponentContext context) throws Throwable {
XConnection connection =
Connector.create(context).connect(getConnectionDescription());
- XBridgeFactory factory = (XBridgeFactory) UnoRuntime.queryInterface(
+ XBridgeFactory factory = UnoRuntime.queryInterface(
XBridgeFactory.class,
context.getServiceManager().createInstanceWithContext(
"com.sun.star.bridge.BridgeFactory", context));
diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug92174_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug92174_Test.java
index 292dabde4758..13b61447c320 100644
--- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug92174_Test.java
+++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug92174_Test.java
@@ -55,7 +55,7 @@ public final class Bug92174_Test extends ComplexTestCase {
}
protected boolean run(XComponentContext context) throws Throwable {
- XTransport t = (XTransport) UnoRuntime.queryInterface(
+ XTransport t = UnoRuntime.queryInterface(
XTransport.class, getBridge(context).getInstance("Transport"));
t.setDerived(new XDerived() {
public void fn() {}
diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug97697_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug97697_Test.java
index f235ccfd6475..2fdd457f0dcb 100644
--- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug97697_Test.java
+++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug97697_Test.java
@@ -72,7 +72,7 @@ public final class Bug97697_Test extends ComplexTestCase {
}
protected boolean run(XComponentContext context) throws Throwable {
- XTransport transport = (XTransport) UnoRuntime.queryInterface(
+ XTransport transport = UnoRuntime.queryInterface(
XTransport.class, getBridge(context).getInstance("Transport"));
try {
transport.getAny();
diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug98508_Test.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug98508_Test.java
index b713deaa352e..79e373014c4a 100644
--- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug98508_Test.java
+++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/Bug98508_Test.java
@@ -76,7 +76,7 @@ public final class Bug98508_Test extends ComplexTestCase {
protected boolean run(XComponentContext context) throws Throwable {
Test98508Interface ifc
- = (Test98508Interface) UnoRuntime.queryInterface(
+ = UnoRuntime.queryInterface(
Test98508Interface.class,
getBridge(context).getInstance(""));
try {
diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/MethodIdTest.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/MethodIdTest.java
index c22811502e14..407164c66c7f 100755
--- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/MethodIdTest.java
+++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/MethodIdTest.java
@@ -64,7 +64,7 @@ public final class MethodIdTest extends ComplexTestCase {
}
protected boolean run(XComponentContext context) throws Throwable {
- XTest t = (XTest) UnoRuntime.queryInterface(
+ XTest t = UnoRuntime.queryInterface(
XTest.class, getBridge(context).getInstance("Test"));
return t.f129() == 129;
}
diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/PolyStructTest.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/PolyStructTest.java
index 2f17041a52fb..1c9e387ddb32 100644
--- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/PolyStructTest.java
+++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/PolyStructTest.java
@@ -61,7 +61,7 @@ public final class PolyStructTest extends ComplexTestCase {
}
protected boolean run(XComponentContext context) throws Throwable {
- TestTransport t = (TestTransport) UnoRuntime.queryInterface(
+ TestTransport t = UnoRuntime.queryInterface(
TestTransport.class, getBridge(context).getInstance(""));
assertEquals(
diff --git a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/StopMessageDispatcherTest.java b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/StopMessageDispatcherTest.java
index 7590a89fdd0e..37fb8ffee05b 100644
--- a/bridges/test/com/sun/star/lib/uno/bridges/java_remote/StopMessageDispatcherTest.java
+++ b/bridges/test/com/sun/star/lib/uno/bridges/java_remote/StopMessageDispatcherTest.java
@@ -63,7 +63,7 @@ public final class StopMessageDispatcherTest extends ComplexTestCase {
}
protected boolean run(XComponentContext context) throws Throwable {
- XTest test = (XTest) UnoRuntime.queryInterface(
+ XTest test = UnoRuntime.queryInterface(
XTest.class, getBridge(context).getInstance("Test"));
Thread[] threads = new Thread[101];
int n = Thread.enumerate(threads);
diff --git a/bridges/test/java_uno/acquire/TestAcquire.java b/bridges/test/java_uno/acquire/TestAcquire.java
index 7d54c00d480d..e219b3adbf72 100644
--- a/bridges/test/java_uno/acquire/TestAcquire.java
+++ b/bridges/test/java_uno/acquire/TestAcquire.java
@@ -71,7 +71,7 @@ public final class TestAcquire {
private static void execClient(XComponentContext context, String url)
throws Exception
{
- XTest test = (XTest) UnoRuntime.queryInterface(
+ XTest test = UnoRuntime.queryInterface(
XTest.class, UnoUrlResolver.create(context).resolve(url));
WaitUnreachable u;
@@ -184,7 +184,7 @@ public final class TestAcquire {
throws Exception
{
XAcceptor acceptor = Acceptor.create(context);
- XBridgeFactory factory = (XBridgeFactory) UnoRuntime.queryInterface(
+ XBridgeFactory factory = UnoRuntime.queryInterface(
XBridgeFactory.class,
context.getServiceManager().createInstanceWithContext(
"com.sun.star.bridge.BridgeFactory", context));
diff --git a/bridges/test/java_uno/any/TestRemote.java b/bridges/test/java_uno/any/TestRemote.java
index db33efc139e9..ec533054579d 100644
--- a/bridges/test/java_uno/any/TestRemote.java
+++ b/bridges/test/java_uno/any/TestRemote.java
@@ -49,7 +49,7 @@ public final class TestRemote {
}
protected boolean run(XComponentContext context) throws Throwable {
- XTransport transport = (XTransport) UnoRuntime.queryInterface(
+ XTransport transport = UnoRuntime.queryInterface(
XTransport.class, getBridge(context).getInstance("Transport"));
return TestAny.test(transport, true);
}
diff --git a/bridges/test/java_uno/equals/TestEquals.java b/bridges/test/java_uno/equals/TestEquals.java
index 31b735473c9b..38c9500629e3 100644
--- a/bridges/test/java_uno/equals/TestEquals.java
+++ b/bridges/test/java_uno/equals/TestEquals.java
@@ -91,10 +91,10 @@ public final class TestEquals {
}
protected boolean run(XComponentContext context) throws Throwable {
- XTestFrame f = (XTestFrame) UnoRuntime.queryInterface(
+ XTestFrame f = UnoRuntime.queryInterface(
XTestFrame.class, getBridge(context).getInstance("TestFrame"));
XAcceptor acceptor = Acceptor.create(context);
- XBridgeFactory factory = (XBridgeFactory) UnoRuntime.queryInterface(
+ XBridgeFactory factory = UnoRuntime.queryInterface(
XBridgeFactory.class,
context.getServiceManager().createInstanceWithContext(
"com.sun.star.bridge.BridgeFactory", context));
@@ -160,17 +160,15 @@ public final class TestEquals {
public void run() {
try {
Object test1Aa = object1;
- XBase test1Ab = (XBase)
- UnoRuntime.queryInterface(
- XBase.class, test1Aa);
- XDerived test1Ac = (XDerived)
+ XBase test1Ab = UnoRuntime.queryInterface(
+ XBase.class, test1Aa);
+ XDerived test1Ac =
UnoRuntime.queryInterface(
XDerived.class, test1Aa);
Object test2Aa = object2;
- XBase test2Ab = (XBase)
- UnoRuntime.queryInterface(
- XBase.class, test2Aa);
- XDerived test2Ac = (XDerived)
+ XBase test2Ab = UnoRuntime.queryInterface(
+ XBase.class, test2Aa);
+ XDerived test2Ac =
UnoRuntime.queryInterface(
XDerived.class, test2Aa);
@@ -182,16 +180,14 @@ public final class TestEquals {
null, params);
XMultiComponentFactory factory
= context.getServiceManager();
- XImplementationLoader loader
- = (XImplementationLoader)
+ XImplementationLoader loader =
UnoRuntime.queryInterface(
XImplementationLoader.class,
factory.createInstanceWithContext(
"com.sun.star.loader."
+ "SharedLibrary",
context));
- XSingleComponentFactory factory2
- = (XSingleComponentFactory)
+ XSingleComponentFactory factory2 =
UnoRuntime.queryInterface(
XSingleComponentFactory.class,
loader.activate(
@@ -199,7 +195,7 @@ public final class TestEquals {
+ "testequals.impl",
"", "../lib/testequals.uno",
null));
- XTestInterface test = (XTestInterface)
+ XTestInterface test =
UnoRuntime.queryInterface(
XTestInterface.class,
factory2.createInstanceWithContext(
@@ -211,17 +207,15 @@ public final class TestEquals {
PROTOCOL_DESCRIPTION);
Object test1Ba = test.get(INSTANCE1);
- XBase test1Bb = (XBase)
- UnoRuntime.queryInterface(
- XBase.class, test1Ba);
- XDerived test1Bc = (XDerived)
+ XBase test1Bb = UnoRuntime.queryInterface(
+ XBase.class, test1Ba);
+ XDerived test1Bc =
UnoRuntime.queryInterface(
XDerived.class, test1Ba);
Object test2Ba = test.get(INSTANCE2);
- XBase test2Bb = (XBase)
- UnoRuntime.queryInterface(
- XBase.class, test2Ba);
- XDerived test2Bc = (XDerived)
+ XBase test2Bb = UnoRuntime.queryInterface(
+ XBase.class, test2Ba);
+ XDerived test2Bc =
UnoRuntime.queryInterface(
XDerived.class, test2Ba);
diff --git a/bridges/test/java_uno/nativethreadpool/Relay.java b/bridges/test/java_uno/nativethreadpool/Relay.java
index b7e304c4a3c9..03cf6795c596 100644
--- a/bridges/test/java_uno/nativethreadpool/Relay.java
+++ b/bridges/test/java_uno/nativethreadpool/Relay.java
@@ -63,7 +63,7 @@ public final class Relay implements XRelay, XSource {
final XAcceptor acceptor = Acceptor.create(context);
final XBridgeFactory factory;
try {
- factory = (XBridgeFactory) UnoRuntime.queryInterface(
+ factory = UnoRuntime.queryInterface(
XBridgeFactory.class,
context.getServiceManager().createInstanceWithContext(
"com.sun.star.bridge.BridgeFactory", context));
diff --git a/bridges/test/testclient.java b/bridges/test/testclient.java
index 244264fa8686..e1733bbc8b10 100644
--- a/bridges/test/testclient.java
+++ b/bridges/test/testclient.java
@@ -121,7 +121,7 @@ public class testclient
XConnector xConnector =
- ( XConnector ) UnoRuntime.queryInterface( XConnector.class , x );
+ UnoRuntime.queryInterface( XConnector.class , x );
XConnection xConnection = xConnector.connect(args[0]);
@@ -138,7 +138,7 @@ public class testclient
System.out.println( "after building bridge" );
// Object rInitialObject = m_bridge.mapInterfaceFrom(rootOid, XInterface.class);
-// XTestFactory rFactory = (XTestFactory )
+// XTestFactory rFactory =
// UnoRuntime.queryInterface(XTestFactory.class,rInitialObject );
// XCallMe callMerFactory->
diff --git a/cli_ure/version/version.txt b/cli_ure/version/version.txt
index d6115b807f62..4676c40d4c95 100644
--- a/cli_ure/version/version.txt
+++ b/cli_ure/version/version.txt
@@ -29,23 +29,23 @@
#
#*************************************************************************
-CLI_URETYPES_NEW_VERSION=1.0.3.0
-CLI_URETYPES_OLD_VERSION=1.0.0.0-1.0.2.0
-CLI_URETYPES_POLICY_VERSION=3.0.0.0
+CLI_URETYPES_NEW_VERSION=1.0.4.0
+CLI_URETYPES_OLD_VERSION=1.0.0.0-1.0.3.0
+CLI_URETYPES_POLICY_VERSION=4.0.0.0
CLI_URETYPES_POLICY_ASSEMBLY=policy.1.0.cli_uretypes
-CLI_BASETYPES_NEW_VERSION=1.0.14.0
-CLI_BASETYPES_OLD_VERSION=1.0.0.0-1.0.13.0
-CLI_BASETYPES_POLICY_VERSION=14.0.0.0
+CLI_BASETYPES_NEW_VERSION=1.0.15.0
+CLI_BASETYPES_OLD_VERSION=1.0.0.0-1.0.14.0
+CLI_BASETYPES_POLICY_VERSION=15.0.0.0
CLI_BASETYPES_POLICY_ASSEMBLY=policy.1.0.cli_basetypes
-CLI_URE_NEW_VERSION=1.0.17.0
-CLI_URE_OLD_VERSION=1.0.0.0-1.0.16.0
-CLI_URE_POLICY_VERSION=17.0.0.0
+CLI_URE_NEW_VERSION=1.0.18.0
+CLI_URE_OLD_VERSION=1.0.0.0-1.0.17.0
+CLI_URE_POLICY_VERSION=18.0.0.0
CLI_URE_POLICY_ASSEMBLY=policy.1.0.cli_ure
-CLI_CPPUHELPER_NEW_VERSION=1.0.17.0
-CLI_CPPUHELPER_OLD_VERSION=1.0.0.0-1.0.16.0
-CLI_CPPUHELPER_POLICY_VERSION=17.0.0.0
+CLI_CPPUHELPER_NEW_VERSION=1.0.18.0
+CLI_CPPUHELPER_OLD_VERSION=1.0.0.0-1.0.17.0
+CLI_CPPUHELPER_POLICY_VERSION=18.0.0.0
CLI_CPPUHELPER_POLICY_ASSEMBLY=policy.1.0.cli_cppuhelper
diff --git a/cpputools/source/regcomplazy/regcomplazy.cxx b/cpputools/source/regcomplazy/regcomplazy.cxx
index 69fd77446156..abcb2c187c08 100755
--- a/cpputools/source/regcomplazy/regcomplazy.cxx
+++ b/cpputools/source/regcomplazy/regcomplazy.cxx
@@ -131,6 +131,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
sBuffer.append(pBuffer, readSize);
}
}
+ fclose(fDescr);
+ fDescr = 0; // just to be sure noone tries to use the file ever after
}
OString sDescr = sBuffer.makeStringAndClear();
diff --git a/io/inc/makefile.mk b/io/inc/makefile.mk
index 7a15edc58216..ce9aa9036c6a 100644
--- a/io/inc/makefile.mk
+++ b/io/inc/makefile.mk
@@ -36,16 +36,18 @@ TARGET=inc
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
-
+.IF "$(L10N_framework)"==""
# --- Files --------------------------------------------------------
# --- Targets -------------------------------------------------------
+.ENDIF # L10N_framework
.INCLUDE : target.mk
-
+.IF "$(L10N_framework)"==""
.IF "$(ENABLE_PCH)"!=""
ALLTAR : \
$(SLO)$/precompiled.pch \
$(SLO)$/precompiled_ex.pch
.ENDIF # "$(ENABLE_PCH)"!=""
+.ENDIF # L10N_framework
diff --git a/io/source/TextInputStream/makefile.mk b/io/source/TextInputStream/makefile.mk
index fcca36f0e576..1fb5aa33743a 100644
--- a/io/source/TextInputStream/makefile.mk
+++ b/io/source/TextInputStream/makefile.mk
@@ -37,6 +37,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
DLLPRE =
SLOFILES= \
@@ -59,5 +60,6 @@ SHL1RPATH= URELIB
DEF1NAME= $(SHL1TARGET)
# --- Targets ------------------------------------------------------
+.ENDIF # L10N_framework
.INCLUDE : target.mk
diff --git a/io/source/TextOutputStream/makefile.mk b/io/source/TextOutputStream/makefile.mk
index 5359458ad8b4..7a4c0d6ba37f 100644
--- a/io/source/TextOutputStream/makefile.mk
+++ b/io/source/TextOutputStream/makefile.mk
@@ -37,6 +37,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
DLLPRE =
# ------------------------------------------------------------------
@@ -60,5 +61,6 @@ SHL1RPATH= URELIB
DEF1NAME= $(SHL1TARGET)
# --- Targets ------------------------------------------------------
+.ENDIF # L10N_framework
.INCLUDE : target.mk
diff --git a/io/source/acceptor/makefile.mk b/io/source/acceptor/makefile.mk
index b537b2087078..843f26296dae 100644
--- a/io/source/acceptor/makefile.mk
+++ b/io/source/acceptor/makefile.mk
@@ -40,6 +40,7 @@ COMPRDB=$(SOLARBINDIR)$/udkapi.rdb
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
DLLPRE =
# ------------------------------------------------------------------
@@ -71,4 +72,6 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def
DEF1NAME= $(SHL1TARGET)
# --- Targets ------------------------------------------------------
+.ENDIF # L10N_framework
+
.INCLUDE : target.mk
diff --git a/io/source/connector/makefile.mk b/io/source/connector/makefile.mk
index d726ac4c87c7..471f6b9d258f 100644
--- a/io/source/connector/makefile.mk
+++ b/io/source/connector/makefile.mk
@@ -40,6 +40,7 @@ COMPRDB=$(SOLARBINDIR)$/udkapi.rdb
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
DLLPRE =
# ------------------------------------------------------------------
@@ -71,5 +72,6 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def
DEF1NAME= $(SHL1TARGET)
# --- Targets ------------------------------------------------------
+.ENDIF # L10N_framework
.INCLUDE : target.mk
diff --git a/io/source/stm/makefile.mk b/io/source/stm/makefile.mk
index e4b8ad326b1d..43b6f2566ddf 100644
--- a/io/source/stm/makefile.mk
+++ b/io/source/stm/makefile.mk
@@ -32,6 +32,7 @@ PRJ=..$/..
PRJNAME=io
TARGET = streams.uno
+
ENABLE_EXCEPTIONS=TRUE
NO_BSYMBOLIC=TRUE
COMP1TYPELIST = stm
@@ -39,6 +40,7 @@ COMPRDB=$(SOLARBINDIR)$/udkapi.rdb
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
DLLPRE =
# --- Files --------------------------------------------------------
UNOUCRDEP=$(SOLARBINDIR)$/udkapi.rdb
@@ -73,5 +75,7 @@ DEF1NAME= $(SHL1TARGET)
# --- Targets ------------------------------------------------------
+.ENDIF # L10N_framework
+
.INCLUDE : target.mk
diff --git a/io/test/makefile.mk b/io/test/makefile.mk
index af032ba8efb1..b7acf670684f 100644
--- a/io/test/makefile.mk
+++ b/io/test/makefile.mk
@@ -41,6 +41,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
# --- Files --------------------------------------------------------
OBJFILES= $(OBJ)$/testcomponent.obj \
@@ -90,5 +91,6 @@ $(BIN)$/applicat.rdb: $(SOLARBINDIR)$/udkapi.rdb
rm -f $@
regmerge $@ / $?
+.ENDIF # L10N_framework
.INCLUDE : target.mk
diff --git a/io/test/stm/makefile.mk b/io/test/stm/makefile.mk
index cb5f6b0c803a..01d334edb998 100644
--- a/io/test/stm/makefile.mk
+++ b/io/test/stm/makefile.mk
@@ -37,6 +37,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
# --- Files --------------------------------------------------------
UNOUCRDEP=$(SOLARBINDIR)$/udkapi.rdb
UNOUCRRDB=$(SOLARBINDIR)$/udkapi.rdb
@@ -97,5 +98,6 @@ DEF1EXPORTFILE= exports.dxp
# --- Targets ------------------------------------------------------
+.ENDIF # L10N_framework
.INCLUDE : target.mk
diff --git a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java b/javaunohelper/com/sun/star/comp/helper/Bootstrap.java
index c5037b2f1566..d80b8a6b9df0 100644
--- a/javaunohelper/com/sun/star/comp/helper/Bootstrap.java
+++ b/javaunohelper/com/sun/star/comp/helper/Bootstrap.java
@@ -67,7 +67,7 @@ import java.util.Random;
Other services can be inserted into the service manager by
using its XSet interface:
<pre>
- XSet xSet = (XSet)UnoRuntime.queryInterface( XSet.class, aMultiComponentFactory );
+ XSet xSet = UnoRuntime.queryInterface( XSet.class, aMultiComponentFactory );
// insert the service manager
xSet.insert( aSingleComponentFactory );
</pre>
@@ -108,20 +108,20 @@ public class Bootstrap {
static public XComponentContext createInitialComponentContext( Hashtable context_entries )
throws Exception
{
- XImplementationLoader xImpLoader = (XImplementationLoader)UnoRuntime.queryInterface(
+ XImplementationLoader xImpLoader = UnoRuntime.queryInterface(
XImplementationLoader.class, new JavaLoader() );
// Get the factory of the ServiceManager
- XSingleComponentFactory smgr_fac = (XSingleComponentFactory)UnoRuntime.queryInterface(
+ XSingleComponentFactory smgr_fac = UnoRuntime.queryInterface(
XSingleComponentFactory.class, xImpLoader.activate(
"com.sun.star.comp.servicemanager.ServiceManager", null, null, null ) );
// Create an instance of the ServiceManager
- XMultiComponentFactory xSMgr = (XMultiComponentFactory)UnoRuntime.queryInterface(
+ XMultiComponentFactory xSMgr = UnoRuntime.queryInterface(
XMultiComponentFactory.class, smgr_fac.createInstanceWithContext( null ) );
// post init loader
- XInitialization xInit = (XInitialization)UnoRuntime.queryInterface(
+ XInitialization xInit = UnoRuntime.queryInterface(
XInitialization.class, xImpLoader );
Object[] args = new Object [] { xSMgr };
xInit.initialize( args );
@@ -137,12 +137,12 @@ public class Bootstrap {
XComponentContext xContext = new ComponentContext( context_entries, null );
// post init smgr
- xInit = (XInitialization)UnoRuntime.queryInterface(
+ xInit = UnoRuntime.queryInterface(
XInitialization.class, xSMgr );
args = new Object [] { null, xContext }; // no registry, default context
xInit.initialize( args );
- XSet xSet = (XSet)UnoRuntime.queryInterface( XSet.class, xSMgr );
+ XSet xSet = UnoRuntime.queryInterface( XSet.class, xSMgr );
// insert the service manager
xSet.insert( smgr_fac );
// and basic jurt factories
@@ -159,7 +159,7 @@ public class Bootstrap {
*/
static public XMultiServiceFactory createSimpleServiceManager() throws Exception
{
- return (XMultiServiceFactory)UnoRuntime.queryInterface(
+ return UnoRuntime.queryInterface(
XMultiServiceFactory.class, createInitialComponentContext( null ).getServiceManager() );
}
@@ -206,7 +206,7 @@ public class Bootstrap {
NativeLibraryLoader.loadLibrary( Bootstrap.class.getClassLoader(), "juh" );
m_loaded_juh = true;
}
- return (XComponentContext)UnoRuntime.queryInterface(
+ return UnoRuntime.queryInterface(
XComponentContext.class,
cppuhelper_bootstrap(
ini_file, pairs, Bootstrap.class.getClassLoader() ) );
@@ -283,7 +283,7 @@ public class Bootstrap {
try {
// try to connect to office
Object context = xUrlResolver.resolve( sConnect );
- xContext = (XComponentContext) UnoRuntime.queryInterface(
+ xContext = UnoRuntime.queryInterface(
XComponentContext.class, context);
if ( xContext == null )
throw new BootstrapException( "no component context!" );
diff --git a/javaunohelper/com/sun/star/comp/helper/ComponentContext.java b/javaunohelper/com/sun/star/comp/helper/ComponentContext.java
index 938cc0543901..1c3df0d4844b 100644
--- a/javaunohelper/com/sun/star/comp/helper/ComponentContext.java
+++ b/javaunohelper/com/sun/star/comp/helper/ComponentContext.java
@@ -101,7 +101,7 @@ public class ComponentContext implements XComponentContext, XComponent
{
o = ((ComponentContextEntry)o).m_value;
}
- m_xSMgr = (XMultiComponentFactory)UnoRuntime.queryInterface(
+ m_xSMgr = UnoRuntime.queryInterface(
XMultiComponentFactory.class, o );
}
if (m_xSMgr != null)
@@ -114,7 +114,7 @@ public class ComponentContext implements XComponentContext, XComponent
}
// listen for delegate
- XComponent xComp = (XComponent)UnoRuntime.queryInterface(
+ XComponent xComp = UnoRuntime.queryInterface(
XComponent.class, m_xDelegate );
if (xComp != null)
{
@@ -154,7 +154,7 @@ public class ComponentContext implements XComponentContext, XComponent
else
{
XSingleComponentFactory xCompFac =
- (XSingleComponentFactory)UnoRuntime.queryInterface(
+ UnoRuntime.queryInterface(
XSingleComponentFactory.class, entry.m_lateInit );
if (xCompFac != null)
{
@@ -185,7 +185,7 @@ public class ComponentContext implements XComponentContext, XComponent
else // inited in the meantime
{
// dispose fresh service instance
- XComponent xComp = (XComponent)UnoRuntime.queryInterface(
+ XComponent xComp = UnoRuntime.queryInterface(
XComponent.class, xInstance );
if (xComp != null)
{
@@ -253,7 +253,7 @@ public class ComponentContext implements XComponentContext, XComponent
o = ((ComponentContextEntry)o).m_value;
}
- XComponent xComp = (XComponent)UnoRuntime.queryInterface( XComponent.class, o );
+ XComponent xComp = UnoRuntime.queryInterface( XComponent.class, o );
if (xComp != null)
{
if (name.equals( TDMGR_NAME ))
@@ -272,7 +272,7 @@ public class ComponentContext implements XComponentContext, XComponent
// smgr
if (m_bDisposeSMgr)
{
- XComponent xComp = (XComponent)UnoRuntime.queryInterface(
+ XComponent xComp = UnoRuntime.queryInterface(
XComponent.class, m_xSMgr );
if (xComp != null)
{
diff --git a/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java b/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java
index 4b5db3753da3..9523fbba7716 100644
--- a/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java
+++ b/javaunohelper/com/sun/star/comp/helper/RegistryServiceFactory.java
@@ -124,7 +124,7 @@ public class RegistryServiceFactory {
Object obj = createRegistryServiceFactory(
writeRegistryFile, readRegistryFile, readOnly,
RegistryServiceFactory.class.getClassLoader() );
- return (XMultiServiceFactory) UnoRuntime.queryInterface(
+ return UnoRuntime.queryInterface(
XMultiServiceFactory.class, obj );
}
diff --git a/javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader.java b/javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader.java
index eda51f8cb1f7..a1bf4d3a168c 100644
--- a/javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader.java
+++ b/javaunohelper/com/sun/star/comp/helper/SharedLibraryLoader.java
@@ -85,7 +85,7 @@ public class SharedLibraryLoader {
XMultiServiceFactory smgr,
XRegistryKey regKey )
{
- return (XSingleServiceFactory) UnoRuntime.queryInterface(
+ return UnoRuntime.queryInterface(
XSingleServiceFactory.class,
component_getFactory(
DEFAULT_LIBRARY, DEFAULT_IMPLEMENTATION, smgr, regKey,
@@ -110,7 +110,7 @@ public class SharedLibraryLoader {
XMultiServiceFactory smgr,
XRegistryKey regKey )
{
- return (XSingleServiceFactory) UnoRuntime.queryInterface(
+ return UnoRuntime.queryInterface(
XSingleServiceFactory.class,
component_getFactory(
libName, impName, smgr, regKey,
diff --git a/javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java b/javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java
index cafa7e0a412d..a508a209ad2c 100644
--- a/javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java
+++ b/javaunohelper/com/sun/star/comp/juhtest/SmoketestCommandEnvironment.java
@@ -119,7 +119,6 @@ class InteractionImpl implements com.sun.star.task.XInteractionHandler
if (approve)
{
com.sun.star.task.XInteractionApprove xApprove =
- (com.sun.star.task.XInteractionApprove)
UnoRuntime.queryInterface(com.sun.star.task.XInteractionApprove.class, conts[i]);
if (xApprove != null)
xApprove.select();
@@ -129,7 +128,6 @@ class InteractionImpl implements com.sun.star.task.XInteractionHandler
else if (abort)
{
com.sun.star.task.XInteractionAbort xAbort =
- (com.sun.star.task.XInteractionAbort)
UnoRuntime.queryInterface(com.sun.star.task.XInteractionAbort.class, conts[i]);
if (xAbort != null)
xAbort.select();
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/Factory.java b/javaunohelper/com/sun/star/lib/uno/helper/Factory.java
index 6eb261ff0eb8..5842c8eaf7f4 100644
--- a/javaunohelper/com/sun/star/lib/uno/helper/Factory.java
+++ b/javaunohelper/com/sun/star/lib/uno/helper/Factory.java
@@ -210,7 +210,7 @@ public class Factory
throws com.sun.star.uno.Exception
{
Object inst = instantiate( xContext );
- XInitialization xInit = (XInitialization)UnoRuntime.queryInterface(
+ XInitialization xInit = UnoRuntime.queryInterface(
XInitialization.class, inst );
if (null == xInit)
{
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java b/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java
index 44a6be5e5f7a..d7bc61cbcbad 100644
--- a/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java
+++ b/javaunohelper/com/sun/star/lib/uno/helper/InterfaceContainer.java
@@ -715,7 +715,7 @@ public class InterfaceContainer implements Cloneable
try
{
Object o= aIt.next();
- XEventListener evtListener= (XEventListener) UnoRuntime.queryInterface(
+ XEventListener evtListener= UnoRuntime.queryInterface(
XEventListener.class, o);
if( evtListener != null )
evtListener.disposing( evt );
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java b/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java
index b4b2d02ab148..d77c1600def3 100644
--- a/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java
+++ b/javaunohelper/com/sun/star/lib/uno/helper/PropertySet.java
@@ -671,7 +671,7 @@ XMultiPropertySet
// We try to get an XInterface of setVal and set an XInterface type.
if (setVal instanceof XInterface)
{
- XInterface xint= (XInterface) UnoRuntime.queryInterface(XInterface.class, setVal);
+ XInterface xint= UnoRuntime.queryInterface(XInterface.class, setVal);
if (xint != null)
convObj= new Any(new Type(XInterface.class), xint);
}
diff --git a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java b/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java
index af33c5ea3ee9..40c69a90f8a6 100644
--- a/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java
+++ b/javaunohelper/com/sun/star/lib/uno/helper/PropertySetMixin.java
@@ -143,13 +143,13 @@ public final class PropertySetMixin {
idlClass = getReflection(type.getTypeName());
XTypeDescription ifc;
try {
- ifc = (XTypeDescription) UnoRuntime.queryInterface(
+ ifc = UnoRuntime.queryInterface(
XTypeDescription.class,
- (((XHierarchicalNameAccess) UnoRuntime.queryInterface(
- XHierarchicalNameAccess.class,
- context.getValueByName(
- "/singletons/com.sun.star.reflection."
- + "theTypeDescriptionManager"))).
+ (UnoRuntime.queryInterface(
+ XHierarchicalNameAccess.class,
+ context.getValueByName(
+ "/singletons/com.sun.star.reflection."
+ + "theTypeDescriptionManager")).
getByHierarchicalName(type.getTypeName())));
} catch (NoSuchElementException e) {
throw new RuntimeException(
@@ -585,7 +585,7 @@ public final class PropertySetMixin {
private XIdlClass getReflection(String typeName) {
XIdlReflection refl;
try {
- refl = (XIdlReflection) UnoRuntime.queryInterface(
+ refl = UnoRuntime.queryInterface(
XIdlReflection.class,
context.getServiceManager().createInstanceWithContext(
"com.sun.star.reflection.CoreReflection", context));
@@ -599,8 +599,7 @@ public final class PropertySetMixin {
try {
return refl.forName(typeName);
} finally {
- XComponent comp = (XComponent) UnoRuntime.queryInterface(
- XComponent.class, refl);
+ XComponent comp = UnoRuntime.queryInterface(XComponent.class, refl);
if (comp != null) {
comp.dispose();
}
@@ -610,9 +609,8 @@ public final class PropertySetMixin {
private void initProperties(
XTypeDescription type, HashMap map, ArrayList handleNames, HashSet seen)
{
- XInterfaceTypeDescription2 ifc = (XInterfaceTypeDescription2)
- UnoRuntime.queryInterface(
- XInterfaceTypeDescription2.class, resolveTypedefs(type));
+ XInterfaceTypeDescription2 ifc = UnoRuntime.queryInterface(
+ XInterfaceTypeDescription2.class, resolveTypedefs(type));
if (seen.add(ifc.getName())) {
XTypeDescription[] bases = ifc.getBaseTypes();
for (int i = 0; i < bases.length; ++i) {
@@ -622,11 +620,10 @@ public final class PropertySetMixin {
for (int i = 0; i < members.length; ++i) {
if (members[i].getTypeClass() == TypeClass.INTERFACE_ATTRIBUTE)
{
- XInterfaceAttributeTypeDescription2 attr
- = ((XInterfaceAttributeTypeDescription2)
- UnoRuntime.queryInterface(
- XInterfaceAttributeTypeDescription2.class,
- members[i]));
+ XInterfaceAttributeTypeDescription2 attr =
+ UnoRuntime.queryInterface(
+ XInterfaceAttributeTypeDescription2.class,
+ members[i]);
short attrAttribs = 0;
if (attr.isBound()) {
attrAttribs |= PropertyAttribute.BOUND;
@@ -685,7 +682,7 @@ public final class PropertySetMixin {
break;
}
attrAttribs |= n;
- t = ((XStructTypeDescription) UnoRuntime.queryInterface(
+ t = (UnoRuntime.queryInterface(
XStructTypeDescription.class, t)).
getTypeArguments()[0];
}
@@ -747,14 +744,14 @@ public final class PropertySetMixin {
object, illegalArgumentPosition);
}
- XIdlField2 f = (XIdlField2) UnoRuntime.queryInterface(
+ XIdlField2 f = UnoRuntime.queryInterface(
XIdlField2.class, idlClass.getField(name));
Object[] o = new Object[] {
new Any(type, UnoRuntime.queryInterface(type, object)) };
Object v = wrapValue(
value,
- ((XIdlField2) UnoRuntime.queryInterface(
- XIdlField2.class, idlClass.getField(name))).getType(),
+ UnoRuntime.queryInterface(
+ XIdlField2.class, idlClass.getField(name)).getType(),
(p.property.Attributes & PropertyAttribute.MAYBEAMBIGUOUS) != 0,
isAmbiguous,
(p.property.Attributes & PropertyAttribute.MAYBEDEFAULT) != 0,
@@ -807,7 +804,7 @@ public final class PropertySetMixin {
if (p == null) {
throw new UnknownPropertyException(name, object);
}
- XIdlField2 field = (XIdlField2) UnoRuntime.queryInterface(
+ XIdlField2 field = UnoRuntime.queryInterface(
XIdlField2.class, idlClass.getField(name));
Object value;
try {
@@ -848,12 +845,12 @@ public final class PropertySetMixin {
XIdlClass ambiguous = getReflection(typeName);
try {
isAmbiguous = AnyConverter.toBoolean(
- ((XIdlField2) UnoRuntime.queryInterface(
+ UnoRuntime.queryInterface(
XIdlField2.class,
- ambiguous.getField("IsAmbiguous"))).get(value));
- value = ((XIdlField2) UnoRuntime.queryInterface(
- XIdlField2.class,
- ambiguous.getField("Value"))).get(value);
+ ambiguous.getField("IsAmbiguous")).get(value));
+ value = UnoRuntime.queryInterface(
+ XIdlField2.class,
+ ambiguous.getField("Value")).get(value);
} catch (com.sun.star.lang.IllegalArgumentException e) {
throw new RuntimeException(
"unexpected"
@@ -867,12 +864,12 @@ public final class PropertySetMixin {
XIdlClass defaulted = getReflection(typeName);
try {
isDefaulted = AnyConverter.toBoolean(
- ((XIdlField2) UnoRuntime.queryInterface(
+ UnoRuntime.queryInterface(
XIdlField2.class,
- defaulted.getField("IsDefaulted"))).get(value));
- value = ((XIdlField2) UnoRuntime.queryInterface(
- XIdlField2.class,
- defaulted.getField("Value"))).get(value);
+ defaulted.getField("IsDefaulted")).get(value));
+ value = UnoRuntime.queryInterface(
+ XIdlField2.class,
+ defaulted.getField("Value")).get(value);
} catch (com.sun.star.lang.IllegalArgumentException e) {
throw new RuntimeException(
"unexpected"
@@ -886,16 +883,16 @@ public final class PropertySetMixin {
XIdlClass optional = getReflection(typeName);
try {
boolean present = AnyConverter.toBoolean(
- ((XIdlField2) UnoRuntime.queryInterface(
+ UnoRuntime.queryInterface(
XIdlField2.class,
- optional.getField("IsPresent"))).get(value));
+ optional.getField("IsPresent")).get(value));
if (!present) {
value = Any.VOID;
break;
}
- value = ((XIdlField2) UnoRuntime.queryInterface(
- XIdlField2.class,
- optional.getField("Value"))).get(value);
+ value = UnoRuntime.queryInterface(
+ XIdlField2.class,
+ optional.getField("Value")).get(value);
} catch (com.sun.star.lang.IllegalArgumentException e) {
throw new RuntimeException(
"unexpected"
@@ -932,15 +929,15 @@ public final class PropertySetMixin {
Object[] strct = new Object[1];
type.createObject(strct);
try {
- XIdlField2 field = (XIdlField2) UnoRuntime.queryInterface(
+ XIdlField2 field = UnoRuntime.queryInterface(
XIdlField2.class, type.getField("Value"));
field.set(
strct,
wrapValue(
value, field.getType(), false, false, wrapDefaulted,
isDefaulted, wrapOptional));
- ((XIdlField2) UnoRuntime.queryInterface(
- XIdlField2.class, type.getField("IsAmbiguous"))).set(
+ UnoRuntime.queryInterface(
+ XIdlField2.class, type.getField("IsAmbiguous")).set(
strct, new Boolean(isAmbiguous));
} catch (com.sun.star.lang.IllegalArgumentException e) {
throw new RuntimeException(
@@ -959,15 +956,15 @@ public final class PropertySetMixin {
Object[] strct = new Object[1];
type.createObject(strct);
try {
- XIdlField2 field = (XIdlField2) UnoRuntime.queryInterface(
+ XIdlField2 field = UnoRuntime.queryInterface(
XIdlField2.class, type.getField("Value"));
field.set(
strct,
wrapValue(
value, field.getType(), wrapAmbiguous, isAmbiguous,
false, false, wrapOptional));
- ((XIdlField2) UnoRuntime.queryInterface(
- XIdlField2.class, type.getField("IsDefaulted"))).set(
+ UnoRuntime.queryInterface(
+ XIdlField2.class, type.getField("IsDefaulted")).set(
strct, new Boolean(isDefaulted));
} catch (com.sun.star.lang.IllegalArgumentException e) {
throw new RuntimeException(
@@ -986,11 +983,11 @@ public final class PropertySetMixin {
type.createObject(strct);
boolean present = !AnyConverter.isVoid(value);
try {
- ((XIdlField2) UnoRuntime.queryInterface(
- XIdlField2.class, type.getField("IsPresent"))).set(
+ UnoRuntime.queryInterface(
+ XIdlField2.class, type.getField("IsPresent")).set(
strct, new Boolean(present));
if (present) {
- XIdlField2 field = (XIdlField2) UnoRuntime.queryInterface(
+ XIdlField2 field = UnoRuntime.queryInterface(
XIdlField2.class, type.getField("Value"));
field.set(
strct,
@@ -1018,9 +1015,8 @@ public final class PropertySetMixin {
private static XTypeDescription resolveTypedefs(XTypeDescription type) {
while (type.getTypeClass() == TypeClass.TYPEDEF) {
- type = ((XIndirectTypeDescription) UnoRuntime.queryInterface(
- XIndirectTypeDescription.class, type)).
- getReferencedType();
+ type = UnoRuntime.queryInterface(
+ XIndirectTypeDescription.class, type).getReferencedType();
}
return type;
}
diff --git a/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java b/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java
index 9c330539e620..b94b85771d8d 100644
--- a/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java
+++ b/javaunohelper/test/com/sun/star/comp/helper/Bootstrap_Test.java
@@ -62,7 +62,7 @@ public class Bootstrap_Test {
"no /singletons/com.sun.star.reflection.theTypeDescriptionManager!" );
}
- XMultiServiceFactory msf = (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory msf = UnoRuntime.queryInterface(
XMultiServiceFactory.class, xContext.getServiceManager() );
String services[] = msf.getAvailableServiceNames();
System.out.println("Available services are:");
@@ -74,7 +74,7 @@ public class Bootstrap_Test {
for ( int i=0; i<services.length; i++ )
System.out.println(services[i]);
- XComponent xComp = (XComponent)UnoRuntime.queryInterface(
+ XComponent xComp = UnoRuntime.queryInterface(
XComponent.class, xContext );
xComp.dispose();
diff --git a/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java b/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java
index 1188f8752135..f88864f2d3ba 100644
--- a/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java
+++ b/javaunohelper/test/com/sun/star/comp/helper/ComponentContext_Test.java
@@ -88,7 +88,7 @@ public class ComponentContext_Test {
System.err.println( "### bootstrap context test failed: 2!" );
}
- XComponent xComp = (XComponent)UnoRuntime.queryInterface(
+ XComponent xComp = UnoRuntime.queryInterface(
XComponent.class, xInitialContext );
xComp.dispose();
}
diff --git a/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java b/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java
index d12e1accf797..fc4c2c06f463 100644
--- a/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java
+++ b/javaunohelper/test/com/sun/star/comp/helper/SharedLibraryLoader_Test.java
@@ -91,7 +91,7 @@ public class SharedLibraryLoader_Test {
if ( ! test_getSharedLibraryLoaderFactory() )
return false;
- sharedLibraryLoader = (XImplementationLoader) UnoRuntime.queryInterface(
+ sharedLibraryLoader = UnoRuntime.queryInterface(
XImplementationLoader.class, sharedLibraryLoaderFactory.createInstance() );
System.out.print("Test - ");
@@ -115,11 +115,11 @@ public class SharedLibraryLoader_Test {
System.err.println("- get the native ServiceManger factory");
XSingleServiceFactory aSMgrFac =
- (XSingleServiceFactory) UnoRuntime.queryInterface( XSingleServiceFactory.class,
+ UnoRuntime.queryInterface( XSingleServiceFactory.class,
sharedLibraryLoader.activate(NATIVE_SERVICE_MANAGER_IMP_NAME, null, NATIVE_SERVICE_MANAGER_LIB_NAME, null));
System.err.println("- instantiate the native ServiceManger");
- nativeServiceManager = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, aSMgrFac.createInstance() );
+ nativeServiceManager = UnoRuntime.queryInterface( XMultiServiceFactory.class, aSMgrFac.createInstance() );
System.out.print("Test - ");
System.out.println(nativeServiceManager == null? "failed" : "successfull");
@@ -141,12 +141,12 @@ public class SharedLibraryLoader_Test {
System.err.println("- get factory of the Registry");
XSingleServiceFactory aRegFac =
- (XSingleServiceFactory) UnoRuntime.queryInterface( XSingleServiceFactory.class,
+ UnoRuntime.queryInterface( XSingleServiceFactory.class,
sharedLibraryLoader.activate(NATIVE_REGISTRY_IMP_NAME, null, NATIVE_REGISTRY_LIB_NAME, null)
);
System.err.println("- instantiate the Registry");
simpleRegistry =
- (XSimpleRegistry) UnoRuntime.queryInterface( XSimpleRegistry.class, aRegFac.createInstance() );
+ UnoRuntime.queryInterface( XSimpleRegistry.class, aRegFac.createInstance() );
System.out.print("Test - ");
System.out.println(simpleRegistry == null? "failed" : "successfull");
System.out.println("*******************************************************************");
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java
index 1629920ad481..46e7f60b7def 100644
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java
+++ b/javaunohelper/test/com/sun/star/lib/uno/helper/ComponentBase_Test.java
@@ -67,9 +67,9 @@ public class ComponentBase_Test
comp.addEventListener(obj1);
comp.addEventListener(obj2);
comp.addEventListener(obj3);
- comp.addEventListener((XEventListener) UnoRuntime.queryInterface(XEventListener.class, proxyObj1Weak1));
- comp.addEventListener((XEventListener) UnoRuntime.queryInterface(XEventListener.class, proxyObj3Weak2));
- comp.addEventListener((XEventListener) UnoRuntime.queryInterface(XEventListener.class, proxyObj3TypeProv));
+ comp.addEventListener(UnoRuntime.queryInterface(XEventListener.class, proxyObj1Weak1));
+ comp.addEventListener(UnoRuntime.queryInterface(XEventListener.class, proxyObj3Weak2));
+ comp.addEventListener(UnoRuntime.queryInterface(XEventListener.class, proxyObj3TypeProv));
obj1.nDisposingCalled = 0;
obj2.nDisposingCalled = 0;
obj3.nDisposingCalled = 0;
diff --git a/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java b/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java
index 2732fa54331a..732db947b97a 100644
--- a/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java
+++ b/javaunohelper/test/com/sun/star/lib/uno/helper/Factory_Test.java
@@ -120,7 +120,7 @@ public class Factory_Test
//==============================================================================================
static void service_info_test( Object inst )
{
- XServiceInfo xInfo = (XServiceInfo)UnoRuntime.queryInterface( XServiceInfo.class, inst );
+ XServiceInfo xInfo = UnoRuntime.queryInterface( XServiceInfo.class, inst );
if (! xInfo.getImplementationName().equals( m_impl_name ))
{
@@ -159,7 +159,7 @@ public class Factory_Test
// bootstrap service manager
XMultiServiceFactory xMgr = RegistryServiceFactory.create( rdb );
- XPropertySet xProps = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet xProps = UnoRuntime.queryInterface(
XPropertySet.class, xMgr );
XComponentContext xContext = (XComponentContext)AnyConverter.toObject(
new Type( XComponentContext.class ), xProps.getPropertyValue( "DefaultContext" ) );
@@ -172,7 +172,7 @@ public class Factory_Test
new Type( XSimpleRegistry.class ), xProps.getPropertyValue( "Registry" ) );
// register impl
XImplementationRegistration xImpReg =
- (XImplementationRegistration)UnoRuntime.queryInterface(
+ UnoRuntime.queryInterface(
XImplementationRegistration.class,
xContext.getServiceManager().createInstanceWithContext(
"com.sun.star.registry.ImplementationRegistration", xContext ) );
@@ -196,7 +196,7 @@ public class Factory_Test
m_supported_services[ nPos ], xContext ) );
}
- XComponent xComp = (XComponent)UnoRuntime.queryInterface( XComponent.class, xContext );
+ XComponent xComp = UnoRuntime.queryInterface( XComponent.class, xContext );
xComp.dispose();
}
catch (Exception exc)
diff --git a/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java b/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java
index 819ef024acfa..6dd90b3dd590 100644
--- a/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java
+++ b/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java
@@ -134,7 +134,7 @@ public class BridgeFactory implements XBridgeFactory/*, XEventListener*/ {
if (hasName) {
IBridge iBridges[] = UnoRuntime.getBridges();
for(int i = 0; i < iBridges.length; ++ i) {
- XBridge xBridge = (XBridge)UnoRuntime.queryInterface(XBridge.class, iBridges[i]);
+ XBridge xBridge = UnoRuntime.queryInterface(XBridge.class, iBridges[i]);
if(xBridge != null) {
if(xBridge.getName().equals(sName))
@@ -148,7 +148,7 @@ public class BridgeFactory implements XBridgeFactory/*, XEventListener*/ {
try {
IBridge iBridge = UnoRuntime.getBridgeByName("java", context, "remote", context, hasName ? new Object[]{sProtocol, aConnection, anInstanceProvider, sName} : new Object[]{sProtocol, aConnection, anInstanceProvider});
- xBridge = (XBridge)UnoRuntime.queryInterface(XBridge.class, iBridge);
+ xBridge = UnoRuntime.queryInterface(XBridge.class, iBridge);
}
catch(Exception exception) {
throw new com.sun.star.lang.IllegalArgumentException(exception.getMessage());
@@ -171,7 +171,7 @@ public class BridgeFactory implements XBridgeFactory/*, XEventListener*/ {
IBridge iBridges[] = UnoRuntime.getBridges();
for(int i = 0; i < iBridges.length; ++ i) {
- xBridge = (XBridge)UnoRuntime.queryInterface(XBridge.class, iBridges[i]);
+ xBridge = UnoRuntime.queryInterface(XBridge.class, iBridges[i]);
if(xBridge != null) {
if(xBridge.getName().equals(sName))
@@ -199,7 +199,7 @@ public class BridgeFactory implements XBridgeFactory/*, XEventListener*/ {
IBridge iBridges[] = UnoRuntime.getBridges();
for(int i = 0; i < iBridges.length; ++ i) {
- XBridge xBridge = (XBridge)UnoRuntime.queryInterface(XBridge.class, iBridges[i]);
+ XBridge xBridge = UnoRuntime.queryInterface(XBridge.class, iBridges[i]);
if(xBridge != null)
vector.addElement(xBridge);
diff --git a/jurt/com/sun/star/comp/loader/FactoryHelper.java b/jurt/com/sun/star/comp/loader/FactoryHelper.java
index 451e387eb7d6..83c1c567509f 100644
--- a/jurt/com/sun/star/comp/loader/FactoryHelper.java
+++ b/jurt/com/sun/star/comp/loader/FactoryHelper.java
@@ -174,7 +174,7 @@ public class FactoryHelper {
{
if (xContext != null)
{
- return (XMultiServiceFactory)UnoRuntime.queryInterface(
+ return UnoRuntime.queryInterface(
XMultiServiceFactory.class, xContext.getServiceManager() );
}
else
@@ -302,7 +302,7 @@ public class FactoryHelper {
Object instance = _constructor.newInstance( args );
if (bInitCall)
{
- XInitialization xInitialization = (XInitialization)UnoRuntime.queryInterface(
+ XInitialization xInitialization = UnoRuntime.queryInterface(
XInitialization.class, instance );
if (xInitialization != null)
{
diff --git a/jurt/com/sun/star/comp/loader/JavaLoader.java b/jurt/com/sun/star/comp/loader/JavaLoader.java
index 3565be7031a3..cf0d9995d7f6 100644
--- a/jurt/com/sun/star/comp/loader/JavaLoader.java
+++ b/jurt/com/sun/star/comp/loader/JavaLoader.java
@@ -102,7 +102,7 @@ public class JavaLoader implements XImplementationLoader,
{
if (m_xMacroExpander == null)
{
- XPropertySet xProps = (XPropertySet)
+ XPropertySet xProps =
UnoRuntime.queryInterface(
XPropertySet.class, multiServiceFactory );
if (xProps == null)
diff --git a/jurt/com/sun/star/comp/servicemanager/ServiceManager.java b/jurt/com/sun/star/comp/servicemanager/ServiceManager.java
index adb0c54c7e28..b791c6501a36 100644
--- a/jurt/com/sun/star/comp/servicemanager/ServiceManager.java
+++ b/jurt/com/sun/star/comp/servicemanager/ServiceManager.java
@@ -158,7 +158,7 @@ public class ServiceManager implements XMultiServiceFactory,
if (loaderObj == null)
throw new com.sun.star.uno.Exception("Can get an instance of com.sun.star.loader.Java");
- return (XImplementationLoader) UnoRuntime.queryInterface( XImplementationLoader.class, loaderObj );
+ return UnoRuntime.queryInterface( XImplementationLoader.class, loaderObj );
}
/**
@@ -380,7 +380,7 @@ public class ServiceManager implements XMultiServiceFactory,
Object fac = queryServiceFactory( rServiceSpecifier );
if (fac != null)
{
- XSingleComponentFactory xCompFac = (XSingleComponentFactory)UnoRuntime.queryInterface(
+ XSingleComponentFactory xCompFac = UnoRuntime.queryInterface(
XSingleComponentFactory.class, fac );
if (xCompFac != null)
{
@@ -388,7 +388,7 @@ public class ServiceManager implements XMultiServiceFactory,
}
else
{
- XSingleServiceFactory xServiceFac = (XSingleServiceFactory)UnoRuntime.queryInterface(
+ XSingleServiceFactory xServiceFac = UnoRuntime.queryInterface(
XSingleServiceFactory.class, fac );
if (xServiceFac != null)
{
@@ -422,7 +422,7 @@ public class ServiceManager implements XMultiServiceFactory,
Object fac = queryServiceFactory( rServiceSpecifier );
if (fac != null)
{
- XSingleComponentFactory xCompFac = (XSingleComponentFactory)UnoRuntime.queryInterface(
+ XSingleComponentFactory xCompFac = UnoRuntime.queryInterface(
XSingleComponentFactory.class, fac );
if (xCompFac != null)
{
@@ -430,7 +430,7 @@ public class ServiceManager implements XMultiServiceFactory,
}
else
{
- XSingleServiceFactory xServiceFac = (XSingleServiceFactory)UnoRuntime.queryInterface(
+ XSingleServiceFactory xServiceFac = UnoRuntime.queryInterface(
XSingleServiceFactory.class, fac );
if (xServiceFac != null)
{
@@ -528,7 +528,7 @@ public class ServiceManager implements XMultiServiceFactory,
if (object == null)
throw new com.sun.star.uno.RuntimeException("The parameter must not been null");
- XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, object);
+ XServiceInfo xServiceInfo = UnoRuntime.queryInterface(XServiceInfo.class, object);
if (xServiceInfo != null) {
return UnoRuntime.areSame(factoriesByImplNames.get(xServiceInfo.getImplementationName()), object);
@@ -552,7 +552,7 @@ public class ServiceManager implements XMultiServiceFactory,
if (object == null) throw new com.sun.star.lang.IllegalArgumentException();
XServiceInfo xServiceInfo =
- (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, object);
+ UnoRuntime.queryInterface(XServiceInfo.class, object);
if (xServiceInfo == null)
throw new com.sun.star.lang.IllegalArgumentException(
@@ -606,7 +606,7 @@ public class ServiceManager implements XMultiServiceFactory,
);
XServiceInfo xServiceInfo =
- (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, object);
+ UnoRuntime.queryInterface(XServiceInfo.class, object);
if (xServiceInfo == null)
throw new com.sun.star.lang.IllegalArgumentException(
@@ -614,7 +614,7 @@ public class ServiceManager implements XMultiServiceFactory,
);
XSingleServiceFactory xSingleServiceFactory =
- (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, object);
+ UnoRuntime.queryInterface(XSingleServiceFactory.class, object);
if (xSingleServiceFactory == null)
throw new com.sun.star.lang.IllegalArgumentException(
diff --git a/jurt/com/sun/star/comp/urlresolver/UrlResolver.java b/jurt/com/sun/star/comp/urlresolver/UrlResolver.java
index cabd51d42404..6c63ccbd8490 100644
--- a/jurt/com/sun/star/comp/urlresolver/UrlResolver.java
+++ b/jurt/com/sun/star/comp/urlresolver/UrlResolver.java
@@ -102,7 +102,7 @@ public class UrlResolver {
Object rootObject = null;
XBridgeFactory xBridgeFactory= null;
try {
- xBridgeFactory = (XBridgeFactory)UnoRuntime.queryInterface(XBridgeFactory.class,
+ xBridgeFactory = UnoRuntime.queryInterface(XBridgeFactory.class,
_xMultiServiceFactory.createInstance("com.sun.star.bridge.BridgeFactory"));
} catch (com.sun.star.uno.Exception e) {
throw new com.sun.star.uno.RuntimeException(e.getMessage());
@@ -117,7 +117,7 @@ public class UrlResolver {
throw new com.sun.star.uno.RuntimeException(e.getMessage());
}
- XConnector connector_xConnector = (XConnector)UnoRuntime.queryInterface(XConnector.class, connector);
+ XConnector connector_xConnector = UnoRuntime.queryInterface(XConnector.class, connector);
// connect to the server
XConnection xConnection = connector_xConnector.connect(conDcp);
diff --git a/jurt/com/sun/star/uno/WeakReference.java b/jurt/com/sun/star/uno/WeakReference.java
index 3c954efe1cf9..fc3b6f8100ba 100644
--- a/jurt/com/sun/star/uno/WeakReference.java
+++ b/jurt/com/sun/star/uno/WeakReference.java
@@ -61,7 +61,7 @@ public class WeakReference
Object weakImpl= obj.get();
if (weakImpl != null)
{
- XWeak weak= (XWeak) UnoRuntime.queryInterface(XWeak.class, weakImpl);
+ XWeak weak= UnoRuntime.queryInterface(XWeak.class, weakImpl);
if (weak != null)
{
XAdapter adapter= (XAdapter) weak.queryAdapter();
@@ -77,7 +77,7 @@ public class WeakReference
*/
public WeakReference(Object obj)
{
- XWeak weak= (XWeak) UnoRuntime.queryInterface(XWeak.class, obj);
+ XWeak weak= UnoRuntime.queryInterface(XWeak.class, obj);
if (weak != null)
{
XAdapter adapter= (XAdapter) weak.queryAdapter();
diff --git a/jurt/demo/com/sun/star/demo/DemoServer.java b/jurt/demo/com/sun/star/demo/DemoServer.java
index 8715215dcc70..5b0b8201f274 100644
--- a/jurt/demo/com/sun/star/demo/DemoServer.java
+++ b/jurt/demo/com/sun/star/demo/DemoServer.java
@@ -92,12 +92,12 @@ public class DemoServer {
ServiceManager serviceManager = new ServiceManager();
serviceManager.addFactories(neededServices);
- XAcceptor xAcceptor = (XAcceptor)UnoRuntime.queryInterface(XAcceptor.class, serviceManager.createInstance("com.sun.star.connection.Acceptor"));
+ XAcceptor xAcceptor = UnoRuntime.queryInterface(XAcceptor.class, serviceManager.createInstance("com.sun.star.connection.Acceptor"));
System.err.println("waiting for connect...");
XConnection xConnection = xAcceptor.accept(conDcp);
- XBridgeFactory xBridgeFactory = (XBridgeFactory)UnoRuntime.queryInterface(XBridgeFactory.class, serviceManager.createInstance("com.sun.star.bridge.BridgeFactory"));
+ XBridgeFactory xBridgeFactory = UnoRuntime.queryInterface(XBridgeFactory.class, serviceManager.createInstance("com.sun.star.bridge.BridgeFactory"));
XBridge xBridge = xBridgeFactory.createBridge(conDcp + ";" + protDcp, protDcp, xConnection, new InstanceProvider());
}
diff --git a/jurt/demo/com/sun/star/demo/TestOffice.java b/jurt/demo/com/sun/star/demo/TestOffice.java
index 811889898c48..7b86c8e2dd7e 100644
--- a/jurt/demo/com/sun/star/demo/TestOffice.java
+++ b/jurt/demo/com/sun/star/demo/TestOffice.java
@@ -76,7 +76,7 @@ public class TestOffice {
{
byte bytes[][] = new byte[1][];
- XInputStream rIn = (XInputStream)UnoRuntime.queryInterface(XInputStream.class, rOut);
+ XInputStream rIn = UnoRuntime.queryInterface(XInputStream.class, rOut);
if(rIn.available() != 10)
System.err.println("wrong bytes available\n");
@@ -90,11 +90,11 @@ public class TestOffice {
static void testWriter(XComponent rCmp) throws IOException {
- XTextDocument rTextDoc = (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, rCmp);
+ XTextDocument rTextDoc = UnoRuntime.queryInterface(XTextDocument.class, rCmp);
- XText rText = (XText)UnoRuntime.queryInterface(XText.class, rTextDoc.getText());
- XTextCursor rCursor = (XTextCursor)UnoRuntime.queryInterface(XTextCursor.class, rText.createTextCursor());
- XTextRange rRange = (XTextRange)UnoRuntime.queryInterface(XTextRange.class, rCursor);
+ XText rText = UnoRuntime.queryInterface(XText.class, rTextDoc.getText());
+ XTextCursor rCursor = UnoRuntime.queryInterface(XTextCursor.class, rText.createTextCursor());
+ XTextRange rRange = UnoRuntime.queryInterface(XTextRange.class, rCursor);
byte pcText[] = new byte[1024];
pcText[0] = 0;
@@ -112,7 +112,7 @@ public class TestOffice {
}
static void testDocument(XMultiServiceFactory rSmgr) throws com.sun.star.uno.Exception, IOException {
- XComponentLoader rLoader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, rSmgr.createInstance("com.sun.star.frame.Desktop"));
+ XComponentLoader rLoader = UnoRuntime.queryInterface(XComponentLoader.class, rSmgr.createInstance("com.sun.star.frame.Desktop"));
String urls[] = new String[] {
"private:factory/swriter",
@@ -148,13 +148,13 @@ public class TestOffice {
}
static void doSomething(Object r) throws com.sun.star.uno.Exception, IOException {
- XNamingService rName = (XNamingService)UnoRuntime.queryInterface(XNamingService.class, r);
+ XNamingService rName = UnoRuntime.queryInterface(XNamingService.class, r);
if(rName != null) {
System.err.println("got the remote naming service !");
Object rXsmgr = rName.getRegisteredObject("StarOffice.ServiceManager");
- XMultiServiceFactory rSmgr = (XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, rXsmgr);
+ XMultiServiceFactory rSmgr = UnoRuntime.queryInterface(XMultiServiceFactory.class, rXsmgr);
if(rSmgr != null) {
System.err.println("got the remote service manager !");
// testPipe(rSmgr);
@@ -183,7 +183,7 @@ public class TestOffice {
smgr.addFactories(neededServices);
Object resolver = smgr.createInstance("com.sun.star.bridge.UnoUrlResolver" );
- XUnoUrlResolver resolver_xUnoUrlResolver = (XUnoUrlResolver)UnoRuntime.queryInterface(XUnoUrlResolver.class, resolver);
+ XUnoUrlResolver resolver_xUnoUrlResolver = UnoRuntime.queryInterface(XUnoUrlResolver.class, resolver);
Object rInitialObject = resolver_xUnoUrlResolver.resolve(argv[0]);
diff --git a/jurt/test/com/sun/star/comp/bridgefactory/BridgeFactory_Test.java b/jurt/test/com/sun/star/comp/bridgefactory/BridgeFactory_Test.java
index 8c6722c9f69a..a5fdccf613f8 100644
--- a/jurt/test/com/sun/star/comp/bridgefactory/BridgeFactory_Test.java
+++ b/jurt/test/com/sun/star/comp/bridgefactory/BridgeFactory_Test.java
@@ -75,7 +75,7 @@ public final class BridgeFactory_Test extends ComplexTestCase {
assure("", UnoRuntime.areSame(xBridge, xBridges[0]));
// dispose the bridge
- XComponent xComponent = (XComponent)UnoRuntime.queryInterface(XComponent.class, xBridge);
+ XComponent xComponent = UnoRuntime.queryInterface(XComponent.class, xBridge);
xComponent.dispose();
@@ -103,7 +103,7 @@ public final class BridgeFactory_Test extends ComplexTestCase {
&& UnoRuntime.areSame(xBridge_new, xBridges[0]));
// dispose the new bridge
- XComponent xComponent_new = (XComponent)UnoRuntime.queryInterface(XComponent.class, xBridge_new);
+ XComponent xComponent_new = UnoRuntime.queryInterface(XComponent.class, xBridge_new);
xComponent_new.dispose();
}
}
diff --git a/jurt/test/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge_Test.java b/jurt/test/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge_Test.java
index 8e71d51a0c6f..ffef8f7664a0 100644
--- a/jurt/test/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge_Test.java
+++ b/jurt/test/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge_Test.java
@@ -132,17 +132,17 @@ public final class java_remote_bridge_Test extends ComplexTestCase {
proxyBXInterface[i] = (XInterface) bridgeB.getInstance(name);
// map object:
- proxyBTestInterface[i] = (TestInterface) UnoRuntime.queryInterface(
+ proxyBTestInterface[i] = UnoRuntime.queryInterface(
TestInterface.class, proxyBXInterface[i]);
proxyBTestInterface[i].function();
// remap object once:
- TestInterface remapped = (TestInterface) UnoRuntime.queryInterface(
+ TestInterface remapped = UnoRuntime.queryInterface(
TestInterface.class, proxyBXInterface[i]);
remapped.function();
// remap object twice:
- remapped = (TestInterface) UnoRuntime.queryInterface(
+ remapped = UnoRuntime.queryInterface(
TestInterface.class, proxyBXInterface[i]);
remapped.function();
}
diff --git a/jurt/workbench/com/sun/star/comp/urlresolver/UrlResolver_Test.java b/jurt/workbench/com/sun/star/comp/urlresolver/UrlResolver_Test.java
index 5e3110d140fa..94686e7135fd 100644
--- a/jurt/workbench/com/sun/star/comp/urlresolver/UrlResolver_Test.java
+++ b/jurt/workbench/com/sun/star/comp/urlresolver/UrlResolver_Test.java
@@ -58,19 +58,19 @@ public class UrlResolver_Test
Object initialObject = urlResolver.resolve(
"uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" );
- XMultiComponentFactory xOfficeFactory= (XMultiComponentFactory) UnoRuntime.queryInterface(
+ XMultiComponentFactory xOfficeFactory= UnoRuntime.queryInterface(
XMultiComponentFactory.class, initialObject );
// retrieve the component context (it's not yet exported from the office)
// Query for the XPropertySet interface.
- XPropertySet xProperySet = ( XPropertySet ) UnoRuntime.queryInterface(
+ XPropertySet xProperySet = UnoRuntime.queryInterface(
XPropertySet.class, xOfficeFactory);
// Get the default context from the office server.
Object oDefaultContext = xProperySet.getPropertyValue( "DefaultContext" );
// Query for the interface XComponentContext.
- XComponentContext xOfficeComponentContext = ( XComponentContext ) UnoRuntime.queryInterface(
+ XComponentContext xOfficeComponentContext = UnoRuntime.queryInterface(
XComponentContext.class, oDefaultContext );
// now create the desktop service
diff --git a/jvmfwk/distributions/OpenOfficeorg/javavendors_freebsd.xml b/jvmfwk/distributions/OpenOfficeorg/javavendors_freebsd.xml
index 020c11b4973e..2dd5fe35f555 100644
--- a/jvmfwk/distributions/OpenOfficeorg/javavendors_freebsd.xml
+++ b/jvmfwk/distributions/OpenOfficeorg/javavendors_freebsd.xml
@@ -7,13 +7,13 @@
<vendorInfos>
<vendor name="Sun Microsystems Inc.">
- <minVersion>1.3.1</minVersion>
+ <minVersion>1.5.0</minVersion>
</vendor>
<vendor name="The FreeBSD Foundation">
<minVersion>1.6.0</minVersion>
</vendor>
<vendor name="Free Software Foundation, Inc.">
- <minVersion>1.4.2</minVersion>
+ <minVersion>1.5.0</minVersion>
</vendor>
</vendorInfos>
diff --git a/jvmfwk/distributions/OpenOfficeorg/javavendors_os2.xml b/jvmfwk/distributions/OpenOfficeorg/javavendors_os2.xml
index 372254d4ee71..2de585472b86 100644
--- a/jvmfwk/distributions/OpenOfficeorg/javavendors_os2.xml
+++ b/jvmfwk/distributions/OpenOfficeorg/javavendors_os2.xml
@@ -7,10 +7,10 @@
<vendorInfos>
<vendor name="Sun Microsystems Inc.">
- <minVersion>1.5.0</minVersion>
+ <minVersion>1.4.2</minVersion>
</vendor>
<vendor name="IBM Corporation">
- <minVersion>1.5.0</minVersion>
+ <minVersion>1.4.2</minVersion>
</vendor>
</vendorInfos>
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx b/jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx
index c80d1c091571..b59a30f887d2 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/otherjre.cxx
@@ -65,11 +65,15 @@ char const* const* OtherInfo::getJavaExePaths(int * size)
char const* const* OtherInfo::getRuntimePaths(int * size)
{
static char const* ar[]= {
-#if defined(WNT) || defined(OS2)
+#if defined(WNT)
"/bin/client/jvm.dll",
"/bin/hotspot/jvm.dll",
"/bin/classic/jvm.dll",
"/bin/jrockit/jvm.dll"
+#elif defined(OS2)
+ "/bin/classic/jvm.dll",
+ "/bin/client/jvm.dll",
+ "/bin/hotspot/jvm.dll"
#elif UNX
#ifdef MACOSX
"/../../../JavaVM"
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjre.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjre.cxx
index fec7d0b60136..247c5092ab44 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjre.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjre.cxx
@@ -74,8 +74,6 @@ char const* const* SunInfo::getRuntimePaths(int * size)
"/bin/classic/jvm.dll"
#elif defined(OS2)
"/bin/classic/jvm.dll",
- "/bin/client/jvm.dll",
- "/bin/hotspot/jvm.dll"
#elif UNX
"/lib/" JFW_PLUGIN_ARCH "/client/libjvm.so",
"/lib/" JFW_PLUGIN_ARCH "/server/libjvm.so",
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx
index f3586af32bb5..56972ea0e66f 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunversion.cxx
@@ -159,7 +159,7 @@ bool SunVersion::init(const char *szVersion)
{
//1.4.1_01-, 1.4.1_01a, the numerical part may only be 2 chars.
int len = pCur - pLast;
- if (len != 2)
+ if (len > 2)
return false;
//we've got the update: 01, 02 etc
strncpy(buf, pLast, len);
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
index 055bdae919f3..a823d551af88 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/util.cxx
@@ -65,6 +65,7 @@ using namespace rtl;
using namespace osl;
using namespace std;
+#define CHAR_POINTER(oustr) ::rtl::OUStringToOString(oustr,RTL_TEXTENCODING_UTF8).pData->buffer
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
#ifdef WNT
#define HKEY_SUN_JRE L"Software\\JavaSoft\\Java Runtime Environment"
@@ -241,9 +242,9 @@ FileHandleReader::readLine(rtl::OString * pLine)
{
if (m_nIndex == m_nSize)
{
- sal_uInt64 nRead;
+ sal_uInt64 nRead = 0;
switch (osl_readFile(
- m_aGuard.getHandle(), m_aBuffer, BUFFER_SIZE, &nRead))
+ m_aGuard.getHandle(), m_aBuffer, sizeof(m_aBuffer), &nRead))
{
case osl_File_E_PIPE: //HACK! for windows
nRead = 0;
@@ -256,8 +257,8 @@ FileHandleReader::readLine(rtl::OString * pLine)
m_nIndex = 0;
m_nSize = static_cast< int >(nRead);
break;
- case osl_File_E_INTR:
- continue;
+ case osl_File_E_INTR:
+ continue;
default:
return RESULT_ERROR;
@@ -449,7 +450,11 @@ bool getJavaProps(const OUString & exePath,
rs = stdoutReader.readLine( & aLine);
if (rs != FileHandleReader::RESULT_OK)
break;
+ JFW_TRACE2(OString("[Java framework] line:\" ")
+ + aLine + OString(" \".\n"));
OUString sLine = decodeOutput(aLine);
+ JFW_TRACE2(OString("[Java framework] line:\" ")
+ + OString( CHAR_POINTER(sLine)) + OString(" \".\n"));
sLine = sLine.trim();
if (sLine.getLength() == 0)
continue;
@@ -483,19 +488,21 @@ bool getJavaProps(const OUString & exePath,
*/
rtl::OUString decodeOutput(const rtl::OString& s)
{
- OUString sEncoded = OStringToOUString(s, RTL_TEXTENCODING_ASCII_US);
OUStringBuffer buff(512);
sal_Int32 nIndex = 0;
do
{
- OUString aToken = sEncoded.getToken( 0, ' ', nIndex );
+ OString aToken = s.getToken( 0, ' ', nIndex );
if (aToken.getLength())
{
- sal_Unicode value = (sal_Unicode) aToken.toInt32();
+ sal_Unicode value = (sal_Unicode)(aToken.toInt32());
buff.append(value);
}
} while (nIndex >= 0);
- return buff.makeStringAndClear();
+
+ OUString sDecoded(buff.makeStringAndClear());
+ JFW_TRACE2(sDecoded);
+ return sDecoded;
}
diff --git a/offapi/com/sun/star/chart2/XDataSeries.idl b/offapi/com/sun/star/chart2/XDataSeries.idl
index 206dac223578..eeebc966511c 100644
--- a/offapi/com/sun/star/chart2/XDataSeries.idl
+++ b/offapi/com/sun/star/chart2/XDataSeries.idl
@@ -58,22 +58,28 @@ module chart2
*/
interface XDataSeries : ::com::sun::star::uno::XInterface
{
- /** set the coordinate system in which this series should be
- represented.
- */
-// void setCoordinateSystem( [in] XCoordinateSystem aCoordSystem );
-
/** @returns
the element at the specified index.
- @param Index
- specifies the position in the array. The first index is 0.
+ @param nIndex
+ specifies the index of the data point within the series. The first index is 0.
@throws com::sun::star::lang::IndexOutOfBoundException
if the index is not valid.
*/
::com::sun::star::beans::XPropertySet getDataPointByIndex( [in] long nIndex )
raises( ::com::sun::star::lang::IndexOutOfBoundsException );
+
+ /** the formatting of the specified data point is cleared
+
+ @param nIndex
+ specifies the index of the data point within the series. The first index is 0.
+ */
+ void resetDataPoint( [in] long nIndex );
+
+ /** all data point formattings are cleared
+ */
+ void resetAllDataPoints();
};
} ; // chart2
diff --git a/offapi/com/sun/star/chart2/XDefaultSizeTransmitter.idl b/offapi/com/sun/star/chart2/XDefaultSizeTransmitter.idl
new file mode 100644
index 000000000000..a834bb310eda
--- /dev/null
+++ b/offapi/com/sun/star/chart2/XDefaultSizeTransmitter.idl
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: XDefaultSizeTransmitter.idl,v $
+ * $Revision: 1.3 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef com_sun_star_chart2_xdefaultsizetransmitter_idl
+#define com_sun_star_chart2_xdefaultsizetransmitter_idl
+
+#ifndef __com_sun_star_uno_XInterface_idl__
+#include <com/sun/star/uno/XInterface.idl>
+#endif
+
+#ifndef __com_sun_star_awt_Size_idl__
+#include <com/sun/star/awt/Size.idl>
+#endif
+
+module com
+{
+module sun
+{
+module star
+{
+module chart2
+{
+
+/** Allows to set a default size. This size will be used in case no further informations are available.
+ */
+interface XDefaultSizeTransmitter : ::com::sun::star::uno::XInterface
+{
+ /** set a default size
+ @param aSize_100TH_MM
+ specifies a size in hundredth mm.
+ */
+ void setDefaultSize( [in] ::com::sun::star::awt::Size aSize_100TH_MM );
+};
+
+} ; // chart2
+} ; // com
+} ; // sun
+} ; // star
+
+
+#endif
diff --git a/offapi/com/sun/star/chart2/makefile.mk b/offapi/com/sun/star/chart2/makefile.mk
index d82862c69268..700ecc633d7a 100644
--- a/offapi/com/sun/star/chart2/makefile.mk
+++ b/offapi/com/sun/star/chart2/makefile.mk
@@ -85,6 +85,7 @@ IDLFILES= \
XDataInterpreter.idl \
XDataSeries.idl \
XDataSeriesContainer.idl \
+ XDefaultSizeTransmitter.idl \
XDiagram.idl \
XDiagramProvider.idl \
XFastPropertyState.idl \
diff --git a/offapi/com/sun/star/document/MediaDescriptor.idl b/offapi/com/sun/star/document/MediaDescriptor.idl
index 7fb3698f90b7..49c9cf285b3a 100644
--- a/offapi/com/sun/star/document/MediaDescriptor.idl
+++ b/offapi/com/sun/star/document/MediaDescriptor.idl
@@ -84,6 +84,12 @@ module com { module sun { module star { module document {
published service MediaDescriptor
{
//-------------------------------------------------------------------------
+ /** May be set by filters or detection services if user has choosen to
+ abort loading/saving, e.g. while entering a password.
+ */
+ [optional,property] boolean Aborted;
+
+ //-------------------------------------------------------------------------
/** document is a template
<p>
diff --git a/offapi/com/sun/star/document/PDFDialog.idl b/offapi/com/sun/star/document/PDFDialog.idl
new file mode 100644
index 000000000000..91d2628e3eab
--- /dev/null
+++ b/offapi/com/sun/star/document/PDFDialog.idl
@@ -0,0 +1,67 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:$
+ * $Revision:$
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __com_sun_star_document_PDFDialog_idl__
+#define __com_sun_star_document_PDFDialog_idl__
+
+#ifndef __com_sun_star_ui_dialogs_FilterOptionsDialog_idl__
+#include <com/sun/star/ui/dialogs/FilterOptionsDialog.idl>
+#endif
+
+//=============================================================================
+
+module com { module sun { module star { module document {
+
+//=============================================================================
+
+/** This service is for a PDFDialog
+ */
+service PDFDialog
+{
+ service com::sun::star::ui::dialogs::FilterOptionsDialog;
+
+ //-------------------------------------------------------------------------
+ /** PDFDialog options can be set as sequence of
+ com.sun.star.beans.PropertyValue at the FilterData property of the
+ MediaDescriptor. The PropertyValues which are supported within the
+ sequence are described in the registry at Office.Common/Filter/PDF/Export
+
+ The source of this registry can be found in following file:
+ "officecfg/registry/schema/org/openoffice/Office/Common.xcs"
+ */
+
+ //-------------------------------------------------------------------------
+};
+
+//=============================================================================
+
+}; }; }; };
+
+#endif
+
diff --git a/offapi/com/sun/star/document/makefile.mk b/offapi/com/sun/star/document/makefile.mk
index f196d99fe095..3bc2db2f9e46 100644
--- a/offapi/com/sun/star/document/makefile.mk
+++ b/offapi/com/sun/star/document/makefile.mk
@@ -71,6 +71,7 @@ IDLFILES=\
OfficeDocument.idl\
OleEmbeddedServerRegistration.idl\
OwnLockOnDocumentRequest.idl\
+ PDFDialog.idl\
PrinterIndependentLayout.idl\
RedlineDisplayType.idl \
Settings.idl\
@@ -105,7 +106,7 @@ IDLFILES=\
XLinkTargetSupplier.idl\
XMimeTypeInfo.idl\
XOOXMLDocumentPropertiesImporter.idl\
- XRedlinesSupplier.idl \
+ XRedlinesSupplier.idl \
XScriptInvocationContext.idl\
XStandaloneDocumentInfo.idl\
XStorageBasedDocument.idl\
diff --git a/offapi/com/sun/star/drawing/framework/XPane2.idl b/offapi/com/sun/star/drawing/framework/XPane2.idl
new file mode 100644
index 000000000000..d1b646f73a31
--- /dev/null
+++ b/offapi/com/sun/star/drawing/framework/XPane2.idl
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: XPane.idl,v $
+ * $Revision: 1.4 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __com_sun_star_drawing_framework_XPane2_idl__
+#define __com_sun_star_drawing_framework_XPane2_idl__
+
+#ifndef __com_sun_star_accessibility_XAccessible_idl__
+#include <com/sun/star/accessibility/XAccessible.idl>
+#endif
+
+module com { module sun { module star { module drawing { module framework {
+
+/** An extension of the XPane interface that adds support for
+ a) showing and hiding the windows that internally belong to the pane and
+ b) setting the accessibility object.
+ This is typically an optional interface.
+*/
+interface XPane2
+{
+ /** Return whether all windows that are used to implement the pane are
+ visible.
+ @Returns <TRUE> when all windows of the pane are visible.
+ */
+ boolean isVisible ();
+
+ /** Hide or show the pane. If there is more than one window used to
+ implement the pane then it is left to the implementation if one,
+ some, or all windows are hidden or shown as long as the pane becomes
+ hidden or visible.
+ @param bIsVisible
+ When <TRUE> then show the pane. Hide it otherwise.
+ */
+ void setVisible ([in] boolean bIsVisible);
+
+ /** Set the accessibility object for the pane. When there is more than
+ one window used to implement the pane then the given accessibility
+ object is usually set at the topmost window. However, the details
+ are implementation dependent.
+ @param xAccessible
+ May be an empty reference.
+ */
+ void setAccessible ([in] ::com::sun::star::accessibility::XAccessible xAccessible);
+
+ /** Return the accessibility object that is currently associated with
+ the windows that implement the pane.
+ */
+ ::com::sun::star::accessibility::XAccessible getAccessible ();
+};
+
+}; }; }; }; }; // ::com::sun::star::drawing::framework
+
+#endif
diff --git a/offapi/com/sun/star/drawing/framework/makefile.mk b/offapi/com/sun/star/drawing/framework/makefile.mk
index 9b6706ad14d6..b5dd8cbcc936 100644
--- a/offapi/com/sun/star/drawing/framework/makefile.mk
+++ b/offapi/com/sun/star/drawing/framework/makefile.mk
@@ -62,6 +62,7 @@ IDLFILES= \
XControllerManager.idl \
XModuleController.idl \
XPane.idl \
+ XPane2.idl \
XPaneBorderPainter.idl \
XRelocatableResource.idl \
XResource.idl \
diff --git a/offapi/com/sun/star/embed/Storage.idl b/offapi/com/sun/star/embed/Storage.idl
index b7c85707cf7f..70e91a66e765 100644
--- a/offapi/com/sun/star/embed/Storage.idl
+++ b/offapi/com/sun/star/embed/Storage.idl
@@ -347,6 +347,19 @@ service Storage
</p>
*/
[property, optional, readonly] boolean HasEncryptedEntries;
+
+ // -----------------------------------------------------------------------
+ /** allows to detect if the storage contains nonencrypted entries.
+
+ <p>
+ In case it is set to <TRUE/> the storage itself and/or a tree of
+ substorages contains nonencrypted streams. Usually in case this
+ property is supported the implementation supports
+ <type>XEncryptionProtectedSource</type> interface.
+ </p>
+ */
+ [property, optional, readonly] boolean HasNonEncryptedEntries;
+
};
//============================================================================
diff --git a/offapi/com/sun/star/modules.idl b/offapi/com/sun/star/modules.idl
index 4a0f4efcd12c..d91c8edad1ff 100644
--- a/offapi/com/sun/star/modules.idl
+++ b/offapi/com/sun/star/modules.idl
@@ -90,6 +90,9 @@ module datatransfer {};
/// Office document related interfaces.
module document {};
+/// Office document content related interfaces.
+module office {};
+
/// Drawing and shape specific interfaces.
module drawing {};
diff --git a/offapi/com/sun/star/office/XAnnotation.idl b/offapi/com/sun/star/office/XAnnotation.idl
new file mode 100644
index 000000000000..ff7c4127bb82
--- /dev/null
+++ b/offapi/com/sun/star/office/XAnnotation.idl
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: XGalleryItem.idl,v $
+ * $Revision: 1.4 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __com_sun_star_office_XAnnotation_idl__
+#define __com_sun_star_office_XAnnotation_idl__
+
+#ifndef __com_sun_star_beans_XPropertySet_idl__
+#include <com/sun/star/beans/XPropertySet.idl>
+#endif
+
+#ifndef __com_sun_star_beans_XMultiPropertySet_idl__
+#include <com/sun/star/beans/XMultiPropertySet.idl>
+#endif
+
+#ifndef __com_sun_star_util_DateTime_idl__
+#include <com/sun/star/util/DateTime.idl>
+#endif
+
+#ifndef __com_sun_star_text_XText_idl__
+#include <com/sun/star/text/XText.idl>
+#endif
+
+#ifndef __com_sun_star_geometry_RealPoint2D_idl__
+#include <com/sun/star/geometry/RealPoint2D.idl>
+#endif
+
+#ifndef __com_sun_star_geometry_RealSize2D_idl__
+#include <com/sun/star/geometry/RealSize2D.idl>
+#endif
+
+#ifndef __com_sun_star_lang_XComponent_idl__
+#include <com/sun/star/lang/XComponent.idl>
+#endif
+
+//=============================================================================
+
+module com { module sun { module star { module office {
+
+//=============================================================================
+
+/** This interface gives access to an annotation inside a document.
+ */
+interface XAnnotation
+{
+ /** All attributes are also available as properties. */
+ interface ::com::sun::star::beans::XPropertySet;
+
+ /** manages the lifetime of this annotation, should only be used
+ by the owner of the annotation which should be the document itself. */
+ interface ::com::sun::star::lang::XComponent;
+
+ /** a reference to the document content this annotation is anchored to. */
+ [attribute, readonly] any Anchor;
+
+ /** this is an optional position that gives the user interface a hint where
+ the annotation should be rendered. This could be an offset to the
+ annotations anchor. */
+ [attribute] ::com::sun::star::geometry::RealPoint2D Position;
+
+ /** this is an optional size that gives the user interface a hint how
+ large the annotation should be rendered. */
+ [attribute] ::com::sun::star::geometry::RealSize2D Size;
+
+ /** stores the full name of the author who created this annotation. */
+ [attribute] string Author;
+
+ /** stores the date and time this annotation was last edited. */
+ [attribute] ::com::sun::star::util::DateTime DateTime;
+
+ /** gives access to the annotations text. */
+ [attribute, readonly] ::com::sun::star::text::XText TextRange;
+};
+
+//=============================================================================
+
+}; }; }; };
+
+#endif
diff --git a/offapi/com/sun/star/office/XAnnotationAccess.idl b/offapi/com/sun/star/office/XAnnotationAccess.idl
new file mode 100644
index 000000000000..074312ef6fec
--- /dev/null
+++ b/offapi/com/sun/star/office/XAnnotationAccess.idl
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: XGalleryItem.idl,v $
+ * $Revision: 1.4 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __com_sun_star_office_XAnnotationAccess_idl__
+#define __com_sun_star_office_XAnnotationAccess_idl__
+
+#ifndef __com_sun_star_office_XAnnotationEnumeration_idl__
+#include <com/sun/star/office/XAnnotationEnumeration.idl>
+#endif
+
+#ifndef __com_sun_star_lang_IllegalArgumentException_idl__
+#include <com/sun/star/office/IllegalArgumentException.idl>
+#endif
+
+#ifndef __com_sun_star_office_XAnnotation_idl__
+#include <com/sun/star/office/XAnnotation.idl>
+#endif
+
+//=============================================================================
+
+module com { module sun { module star { module office {
+
+//=============================================================================
+
+/** This interface gives access to the annotation for a document content.
+ */
+interface XAnnotationAccess
+{
+ /** creates a new annotation and inserts it into the document content.
+ */
+ XAnnotation createAndInsertAnnotation();
+
+ /** removes the annotation from this document content.
+ */
+ void removeAnnotation( [in] XAnnotation annotation ) raises ( com::sun::star::lang::IllegalArgumentException );
+
+ /** @returns
+ a new enumeration object for this annotation container.
+ It returns NULL if there are no objects in this container.
+ */
+ XAnnotationEnumeration createAnnotationEnumeration();
+};
+
+//=============================================================================
+
+}; }; }; };
+
+#endif
diff --git a/offapi/com/sun/star/office/XAnnotationEnumeration.idl b/offapi/com/sun/star/office/XAnnotationEnumeration.idl
new file mode 100644
index 000000000000..e81666e0b698
--- /dev/null
+++ b/offapi/com/sun/star/office/XAnnotationEnumeration.idl
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: XEnumeration.idl,v $
+ * $Revision: 1.12 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __com_sun_star_office_XAnnotationEnumeration_idl__
+#define __com_sun_star_office_XAnnotationEnumeration_idl__
+
+#ifndef __com_sun_star_office_XAnnotation_idl__
+#include <com/sun/star/office/XAnnotation.idl>
+#endif
+
+#ifndef __com_sun_star_container_NoSuchElementException_idl__
+#include <com/sun/star/container/NoSuchElementException.idl>
+#endif
+
+//=============================================================================
+
+module com { module sun { module star { module office {
+
+//=============================================================================
+
+/** An enumeration for a set of annotations.
+ */
+interface XAnnotationEnumeration
+{
+ //-------------------------------------------------------------------------
+
+ /** tests whether this enumeration contains more elements.
+ */
+ boolean hasMoreElements();
+
+ //-------------------------------------------------------------------------
+
+ /** @returns
+ the next element of this enumeration.
+
+ @throws NoSuchElementException
+ if no more elements exist.
+ */
+ XAnnotation nextElement()
+ raises( com::sun::star::container::NoSuchElementException );
+
+};
+
+//=============================================================================
+
+}; }; }; };
+
+#endif
diff --git a/offapi/com/sun/star/office/makefile.mk b/offapi/com/sun/star/office/makefile.mk
new file mode 100644
index 000000000000..404c23c45e32
--- /dev/null
+++ b/offapi/com/sun/star/office/makefile.mk
@@ -0,0 +1,51 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.5 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..
+PRJNAME=offapi
+TARGET=cssoffice
+PACKAGE=com$/sun$/star$/office
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# ------------------------------------------------------------------------
+
+IDLFILES=\
+ XAnnotation.idl\
+ XAnnotationEnumeration.idl\
+ XAnnotationAccess.idl
+
+# ------------------------------------------------------------------
+
+.INCLUDE : target.mk
+.INCLUDE : $(PRJ)$/util$/target.pmk
diff --git a/offapi/com/sun/star/security/DocumentSignatureInformation.idl b/offapi/com/sun/star/security/DocumentSignatureInformation.idl
index da418ebac2d4..4ed6d972705c 100644
--- a/offapi/com/sun/star/security/DocumentSignatureInformation.idl
+++ b/offapi/com/sun/star/security/DocumentSignatureInformation.idl
@@ -59,6 +59,25 @@ struct DocumentSignatureInformation
<type scope="com::sun::star::security">CertificateValidity</type>.
*/
long CertificateStatus;
+ /* indicates what content of a document is signed.
+ <p>
+ This value can be ignored when this struct is returned as part of
+ a macro signature validation.
+ As of OpenOffice.org 3.2 and ODF 1.2 the document signature comprises
+ all files except the signature file itself.
+ Signatures in OOo 2.x were only
+ applied to the files in the root of the document, except mimetype, the
+ Pictures and ObjectReplacements/Objects folder. That is, macros
+ were not part of the document signature.
+ OOo 3.0 signed everthing, execept mimetype and the META-INF folder.
+ <p>
+ If PartialDocumentSignature is true, then the signature was created by OOo
+ with a version less then 3.2. In this case, not all files are signed. The
+ signature can still be regarded as valid, as long as SignatureIsValid is true
+ and the certificate could be validated. However, users should be notified about
+ the fact, that not everything in this document is signed.
+ */
+ boolean PartialDocumentSignature;
};
diff --git a/offapi/com/sun/star/task/DocumentMSPasswordRequest.idl b/offapi/com/sun/star/task/DocumentMSPasswordRequest.idl
index 6e4adec10720..717e590c12ba 100644
--- a/offapi/com/sun/star/task/DocumentMSPasswordRequest.idl
+++ b/offapi/com/sun/star/task/DocumentMSPasswordRequest.idl
@@ -49,7 +49,7 @@ module com { module sun { module star { module task {
the mentioned service are Abort and Approve.
</P>
- @since OOo 3.x.x
+ @since OOo 3.2
*/
published exception DocumentMSPasswordRequest: PasswordRequest
{
diff --git a/offapi/com/sun/star/task/DocumentMacroConfirmationRequest2.idl b/offapi/com/sun/star/task/DocumentMacroConfirmationRequest2.idl
new file mode 100644
index 000000000000..422f1ab2a9d0
--- /dev/null
+++ b/offapi/com/sun/star/task/DocumentMacroConfirmationRequest2.idl
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: DocumentMacroConfirmationRequest.idl,v $
+ * $Revision: 1.3 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __com_sun_star_task_DocumentMacroConfirmationRequest2_idl__
+#define __com_sun_star_task_DocumentMacroConfirmationRequest2_idl__
+
+#include <com/sun/star/task/ClassifiedInteractionRequest.idl>
+#include <com/sun/star/embed/XStorage.idl>
+#include <com/sun/star/security/DocumentSignatureInformation.idl>
+
+
+//=============================================================================
+
+module com { module sun { module star { module task {
+
+//=============================================================================
+
+/** describes the request to approve or deny the execution of macros contained in
+ a document.
+ */
+exception DocumentMacroConfirmationRequest2 : ClassifiedInteractionRequest
+{
+ /** specifies the URL of the document which contains macros whose execution
+ should be approved or rejected.
+ */
+ string DocumentURL;
+
+ /** refers to the zip-storage related to the last commited version of the
+ document.
+
+ This storage is necessary e.g. for displaying the existing signatures to
+ the user, to allow him a decision whether or not to trust those signatures
+ and thus the signed macros.
+
+ @see ::com::sun::star::security::XDocumentDigitalSignatures::showScriptingContentSignatures
+ */
+ ::com::sun::star::embed::XStorage
+ DocumentZipStorage;
+
+ /** contains informations about the ODF version of the document
+ */
+ string DocumentVersion;
+
+ /** contains informations about the signatures in the document
+ */
+ sequence< ::com::sun::star::security::DocumentSignatureInformation >
+ DocumentSignatureInformation;
+};
+
+//=============================================================================
+
+}; }; }; };
+
+//=============================================================================
+
+#endif
diff --git a/offapi/com/sun/star/task/XUrlContainer.idl b/offapi/com/sun/star/task/XUrlContainer.idl
new file mode 100644
index 000000000000..93839e68fb07
--- /dev/null
+++ b/offapi/com/sun/star/task/XUrlContainer.idl
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: XPasswordContainer.idl,v $
+ * $Revision: 1.9 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __com_sun_star_task_XUrlContainer_idl__
+#define __com_sun_star_task_XUrlContainer_idl__
+
+#ifndef __com_sun_star_uno_XInterface_idl__
+#include <com/sun/star/uno/XInterface.idl>
+#endif
+
+#ifndef __com_sun_star_task_XInteractionHandler_idl__
+#include <com/sun/star/task/XInteractionHandler.idl>
+#endif
+
+
+//=============================================================================
+
+module com { module sun { module star { module task {
+
+//=============================================================================
+/** Allows to store and retrieve URLs. URLs can be stored persistently or
+ until end of OOo session.
+*/
+/*published*/ interface XUrlContainer : com::sun::star::uno::XInterface
+{
+ //-------------------------------------------------------------------------
+ /** Add a URL to the container.
+
+ @param Url URL to add to the container
+ @param MakePersistent indicates whether the URL shall be stored
+ persistently or just in memory (until end of
+ OOo session)
+ */
+ void addUrl( [in] string Url, [in] boolean MakePersistent );
+
+ //-------------------------------------------------------------------------
+ /** Lookup a URL in the container.
+
+ @param Url URL to lookup.
+ @returns Best matched URL or empty string.
+ */
+ string findUrl( [in] string Url );
+
+ //-------------------------------------------------------------------------
+ /** Remove a URL from the container.
+
+ @param Url URL to remove.
+ */
+ void removeUrl( [in] string Url );
+
+ //-------------------------------------------------------------------------
+ /** Get all URLs.
+
+ @param OnlyPersistent Only URLs taht are stored persistently shall
+ be returned.
+ @returns List of URLs.
+ */
+ sequence<string> getUrls( [in] boolean OnlyPersistent );
+
+};
+
+//=============================================================================
+
+}; }; }; };
+
+#endif
diff --git a/offapi/com/sun/star/task/makefile.mk b/offapi/com/sun/star/task/makefile.mk
index 1559901f740c..dc54f6fd3883 100644
--- a/offapi/com/sun/star/task/makefile.mk
+++ b/offapi/com/sun/star/task/makefile.mk
@@ -45,6 +45,7 @@ PACKAGE=com$/sun$/star$/task
IDLFILES=\
ClassifiedInteractionRequest.idl\
DocumentMacroConfirmationRequest.idl\
+ DocumentMacroConfirmationRequest2.idl\
DocumentPasswordRequest.idl\
DocumentMSPasswordRequest.idl\
ErrorCodeRequest.idl\
@@ -79,7 +80,8 @@ IDLFILES=\
XStatusIndicatorSupplier.idl\
XAbortChannel.idl\
XInteractionRequestStringResolver.idl\
- InteractionRequestStringResolver.idl
+ InteractionRequestStringResolver.idl\
+ XUrlContainer.idl
# ------------------------------------------------------------------
diff --git a/offapi/com/sun/star/text/InContentMetadata.idl b/offapi/com/sun/star/text/InContentMetadata.idl
new file mode 100644
index 000000000000..7a7a20adc877
--- /dev/null
+++ b/offapi/com/sun/star/text/InContentMetadata.idl
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: TextField.idl,v $
+ * $Revision: 1.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __com_sun_star_text_InContentMetadata_idl__
+#define __com_sun_star_text_InContentMetadata_idl__
+
+#ifndef __com_sun_star_container_XEnumerationAccess_idl__
+#include <com/sun/star/container/XEnumerationAccess.idl>
+#endif
+
+#ifndef __com_sun_star_text_TextContent_idl__
+#include <com/sun/star/text/TextContent.idl>
+#endif
+
+#ifndef __com_sun_star_rdf_XMetadatable_idl__
+#include <com/sun/star/rdf/XMetadatable.idl>
+#endif
+
+
+//=============================================================================
+
+module com { module sun { module star { module text {
+
+//=============================================================================
+
+/** is a <type>TextContent</type> that can be used to attach RDF metadata
+ to a range of text.
+
+ @since OOo 3.2
+ */
+service InContentMetadata
+{
+ //-------------------------------------------------------------------------
+ /** None of the properties of <type>TextContent</type> are
+ supported. */
+ service com::sun::star::text::TextContent;
+
+ //-------------------------------------------------------------------------
+ /** The <type>InContentMetadata</type> can have RDF metadata attached. */
+ interface com::sun::star::rdf::XMetadatable;
+
+ //-------------------------------------------------------------------------
+ /** The <type>TextContent</type>s that are contained in the
+ annotated range of text can be enumerated. */
+ interface com::sun::star::container::XEnumerationAccess;
+
+};
+
+
+//=============================================================================
+
+}; }; }; };
+
+#endif
diff --git a/offapi/com/sun/star/text/TextPortion.idl b/offapi/com/sun/star/text/TextPortion.idl
index 26ad5bd5ba6c..d4ab79f88323 100644
--- a/offapi/com/sun/star/text/TextPortion.idl
+++ b/offapi/com/sun/star/text/TextPortion.idl
@@ -113,6 +113,7 @@ published service TextPortion
<dt>Ruby</dt><dd>a ruby attribute which is used in Asian text</dd>
<dt>Frame</dt><dd>a frame</dd>
<dt>SoftPageBreak</dt><dd>a soft page break</dd>
+ <dt>InContentMetadata</dt><dd>a text range with attached metadata</dd>
</dl>
<p>For Reference marks, document index marks, etc., 2 text portions
will be generated, one for the start position and one for the
@@ -123,6 +124,7 @@ published service TextPortion
//-------------------------------------------------------------------------
/** contains the control character of a text portion of type
ControlCharacter.
+ @deprecated type ControlCharacter no longer implemented
*/
[readonly, property] short ControlCharacter;
@@ -153,6 +155,13 @@ published service TextPortion
::com::sun::star::text::XTextField TextField;
//-------------------------------------------------------------------------
+ /** contains the text range of a text portion of type InContentMetadata.
+ @since OOo 3.2
+ */
+ [optional, readonly, property]
+ ::com::sun::star::text::XTextContent InContentMetadata;
+
+ //-------------------------------------------------------------------------
/** contains whether the portion is a point only. */
[optional, readonly, property] boolean IsCollapsed;
diff --git a/offapi/com/sun/star/text/makefile.mk b/offapi/com/sun/star/text/makefile.mk
index 18ad6abbe2a1..c018c9479049 100644
--- a/offapi/com/sun/star/text/makefile.mk
+++ b/offapi/com/sun/star/text/makefile.mk
@@ -107,6 +107,7 @@ IDLFILES=\
HorizontalAdjust.idl\
HypertextDocument.idl\
IllustrationsIndex.idl\
+ InContentMetadata.idl\
InvalidTextContentException.idl\
LabelFollow.idl\
LineNumberingProperties.idl\
diff --git a/offapi/com/sun/star/text/textfield/MetadataField.idl b/offapi/com/sun/star/text/textfield/MetadataField.idl
new file mode 100644
index 000000000000..f82276213527
--- /dev/null
+++ b/offapi/com/sun/star/text/textfield/MetadataField.idl
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: MetadataField.idl,v $
+ * $Revision: 1.12 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __com_sun_star_text_textfield_MetadataField_idl__
+#define __com_sun_star_text_textfield_MetadataField_idl__
+
+#ifndef __com_sun_star_container_XEnumerationAccess_idl__
+#include <com/sun/star/container/XEnumerationAccess.idl>
+#endif
+
+#ifndef __com_sun_star_text_TextField_idl__
+#include <com/sun/star/text/TextField.idl>
+#endif
+
+#ifndef __com_sun_star_text_XText_idl__
+#include <com/sun/star/text/XText.idl>
+#endif
+
+#ifndef __com_sun_star_rdf_XMetadatable_idl__
+#include <com/sun/star/rdf/XMetadatable.idl>
+#endif
+
+
+//=============================================================================
+
+module com { module sun { module star { module text { module textfield {
+
+//=============================================================================
+/** is a <type>TextField</type> whose content is specified by RDF metadata.
+
+ @since OOo 3.2
+
+ @see com::sun::star::rdf
+*/
+service MetadataField
+{
+ //-------------------------------------------------------------------------
+ /** None of the properties of <type>TextContent</type> are
+ supported. */
+ service com::sun::star::text::TextField;
+
+ //-------------------------------------------------------------------------
+ /** The <type>MetadataField</type> can have RDF metadata attached. */
+ interface com::sun::star::rdf::XMetadatable;
+
+ //-------------------------------------------------------------------------
+ /** Allows for insertion of text content into, and creating cursors
+ that are bound within, the <type>MetadataField</type>. */
+ interface com::sun::star::text::XText;
+
+ //-------------------------------------------------------------------------
+ /** The <type>TextContent</type>s that are contained in the
+ <type>MetadataField</type> can be enumerated. */
+ interface com::sun::star::container::XEnumerationAccess;
+
+ //-------------------------------------------------------------------------
+ /** this is the number format for this field.
+ @see com::sun::star::util::NumberFormatter
+ */
+ [optional, property] long NumberFormat;
+
+ //-------------------------------------------------------------------------
+ /** determines whether changes in language attributes at the
+ position of the text field also change the number format
+ as appropriate for this language.
+ */
+ [optional, property] boolean IsFixedLanguage;
+};
+
+//=============================================================================
+
+}; }; }; }; };
+
+#endif
+
diff --git a/offapi/com/sun/star/text/textfield/makefile.mk b/offapi/com/sun/star/text/textfield/makefile.mk
index 46506a4eff8c..0defebd69dfc 100644
--- a/offapi/com/sun/star/text/textfield/makefile.mk
+++ b/offapi/com/sun/star/text/textfield/makefile.mk
@@ -70,6 +70,7 @@ IDLFILES=\
InputUser.idl\
JumpEdit.idl\
Macro.idl\
+ MetadataField.idl\
PageCount.idl\
PageNumber.idl\
ParagraphCount.idl\
diff --git a/offapi/com/sun/star/ucb/URLAuthenticationRequest.idl b/offapi/com/sun/star/ucb/URLAuthenticationRequest.idl
new file mode 100644
index 000000000000..1b19830df81e
--- /dev/null
+++ b/offapi/com/sun/star/ucb/URLAuthenticationRequest.idl
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: AuthenticationRequest.idl,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __com_sun_star_ucb_URLAuthenticationRequest_idl__
+#define __com_sun_star_ucb_URLAuthenticationRequest_idl__
+
+#ifndef __com_sun_star_ucb_AuthenticationRequest_idl__
+#include <com/sun/star/ucb/AuthenticationRequest.idl>
+#endif
+
+
+//=============================================================================
+
+module com { module sun { module star { module ucb {
+
+//=============================================================================
+/** An error specifing lack of correct authentication data (e.g., to log into
+ an account).
+*/
+/*published*/ exception URLAuthenticationRequest : AuthenticationRequest
+{
+ //-------------------------------------------------------------------------
+ /** The URL for which authentication is requested.
+ */
+ string URL;
+};
+
+//=============================================================================
+
+}; }; }; };
+
+#endif
diff --git a/offapi/com/sun/star/ucb/XInteractionSupplyAuthentication2.idl b/offapi/com/sun/star/ucb/XInteractionSupplyAuthentication2.idl
new file mode 100644
index 000000000000..a3c4bdb3d5f3
--- /dev/null
+++ b/offapi/com/sun/star/ucb/XInteractionSupplyAuthentication2.idl
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: XInteractionSupplyAuthentication.idl,v $
+ * $Revision: 1.9 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __com_sun_star_ucb_XInteractionSupplyAuthentication2_idl__
+#define __com_sun_star_ucb_XInteractionSupplyAuthentication2_idl__
+
+#ifndef __com_sun_star_ucb_XInteractionSupplyAuthentication_idl__
+#include <com/sun/star/ucb/XInteractionSupplyAuthentication.idl>
+#endif
+
+
+
+//=============================================================================
+
+module com { module sun { module star { module ucb {
+
+//=============================================================================
+/** An interaction continuation handing back some authentication data.
+
+ <p> This continuation is typically used in conjunction with
+ <type>AuthenticationRequest</type>. </p>
+*/
+/*published*/ interface XInteractionSupplyAuthentication2 : XInteractionSupplyAuthentication
+{
+ //-------------------------------------------------------------------------
+ /** Specifies if 'system credentials' can be obtained and used by the issuer
+ of the authentiction request.
+
+ @param Default
+ Returns the default behavior for system credentials handling (to be
+ initially displayed to the user).
+
+ @returns
+ <true/> if the issuer is able to obtain and use system credentials.
+ <false/> otherwise.
+ */
+ boolean canUseSystemCredentials( [out] boolean Default );
+
+ //-------------------------------------------------------------------------
+ /** Set a new 'use system credentials' value to hand back.
+
+ @param UseSystemCredentials
+ <true/> means the request issuer shall obtain and use system credentials.
+ */
+ void setUseSystemCredentials( [in] boolean UseSystemCredentials );
+
+};
+
+//=============================================================================
+
+}; }; }; };
+
+#endif
diff --git a/offapi/com/sun/star/ucb/makefile.mk b/offapi/com/sun/star/ucb/makefile.mk
index 2cf5394dcaf4..19320b716634 100644
--- a/offapi/com/sun/star/ucb/makefile.mk
+++ b/offapi/com/sun/star/ucb/makefile.mk
@@ -45,6 +45,7 @@ IDLFILES=\
AlreadyInitializedException.idl\
AnyCompareFactory.idl\
AuthenticationRequest.idl\
+ URLAuthenticationRequest.idl\
CachedContentResultSet.idl\
CachedContentResultSetFactory.idl\
CachedContentResultSetStub.idl\
@@ -99,7 +100,7 @@ IDLFILES=\
FTPContent.idl\
FTPContentProvider.idl\
GlobalTransferCommandArgument.idl\
- GIOContentProvider.idl\
+ GIOContentProvider.idl\
GnomeVFSContentProvider.idl\
GnomeVFSDocumentContent.idl\
GnomeVFSFolderContent.idl\
@@ -142,125 +143,126 @@ IDLFILES=\
LockType.idl\
MissingInputStreamException.idl\
MissingPropertiesException.idl\
- NameClash.idl\
- NameClashException.idl\
- NameClashResolveRequest.idl\
- NumberedSortingInfo.idl\
- ODMAContent.idl\
- ODMAContentProvider.idl\
- OpenCommandArgument.idl\
- OpenCommandArgument2.idl\
- OpenMode.idl\
- OutgoingMessageState.idl\
- PackageContentProvider.idl\
- PackageFolderContent.idl\
- PackageStreamContent.idl\
- PersistentPropertySet.idl\
- PostCommandArgument.idl\
- PostCommandArgument2.idl\
- Priority.idl\
- PropertiesManager.idl\
- PropertySetRegistry.idl\
- PropertyValueInfo.idl\
- PropertyValueState.idl\
- RecipientInfo.idl\
- RememberAuthentication.idl\
- RemoteAccessContentProvider.idl\
- RemoteContentProviderAcceptor.idl\
- RemoteContentProviderChangeAction.idl\
- RemoteContentProviderChangeEvent.idl\
- RemoteProxyContentProvider.idl\
- ResultSetException.idl\
+ NameClash.idl\
+ NameClashException.idl\
+ NameClashResolveRequest.idl\
+ NumberedSortingInfo.idl\
+ ODMAContent.idl\
+ ODMAContentProvider.idl\
+ OpenCommandArgument.idl\
+ OpenCommandArgument2.idl\
+ OpenMode.idl\
+ OutgoingMessageState.idl\
+ PackageContentProvider.idl\
+ PackageFolderContent.idl\
+ PackageStreamContent.idl\
+ PersistentPropertySet.idl\
+ PostCommandArgument.idl\
+ PostCommandArgument2.idl\
+ Priority.idl\
+ PropertiesManager.idl\
+ PropertySetRegistry.idl\
+ PropertyValueInfo.idl\
+ PropertyValueState.idl\
+ RecipientInfo.idl\
+ RememberAuthentication.idl\
+ RemoteAccessContentProvider.idl\
+ RemoteContentProviderAcceptor.idl\
+ RemoteContentProviderChangeAction.idl\
+ RemoteContentProviderChangeEvent.idl\
+ RemoteProxyContentProvider.idl\
+ ResultSetException.idl\
Rule.idl\
- RuleAction.idl\
- RuleOperator.idl\
- RuleSet.idl\
- RuleTerm.idl\
- SearchCommandArgument.idl\
- SearchCriterium.idl\
- SearchInfo.idl\
- SearchRecursion.idl\
- SendInfo.idl\
- SendMediaTypes.idl\
- ServiceNotFoundException.idl\
- SimpleFileAccess.idl\
- SortedDynamicResultSetFactory.idl\
- SortingInfo.idl\
- Store.idl\
- SynchronizePolicy.idl\
- TransferCommandOperation.idl\
- TransferInfo.idl\
- TransferResult.idl\
+ RuleAction.idl\
+ RuleOperator.idl\
+ RuleSet.idl\
+ RuleTerm.idl\
+ SearchCommandArgument.idl\
+ SearchCriterium.idl\
+ SearchInfo.idl\
+ SearchRecursion.idl\
+ SendInfo.idl\
+ SendMediaTypes.idl\
+ ServiceNotFoundException.idl\
+ SimpleFileAccess.idl\
+ SortedDynamicResultSetFactory.idl\
+ SortingInfo.idl\
+ Store.idl\
+ SynchronizePolicy.idl\
+ TransferCommandOperation.idl\
+ TransferInfo.idl\
+ TransferResult.idl\
TransientDocumentsContentProvider.idl\
TransientDocumentsRootContent.idl\
TransientDocumentsDocumentContent.idl\
TransientDocumentsFolderContent.idl\
TransientDocumentsStreamContent.idl\
- UniversalContentBroker.idl\
- UnsupportedCommandException.idl\
- UnsupportedDataSinkException.idl\
- UnsupportedNameClashException.idl\
- UnsupportedOpenModeException.idl\
- VerificationMode.idl\
- WebDAVContentProvider.idl\
- WebDAVDocumentContent.idl\
- WebDAVFolderContent.idl\
- WelcomeDynamicResultSetStruct.idl\
- XAnyCompare.idl\
- XAnyCompareFactory.idl\
- XCachedContentResultSetFactory.idl\
- XCachedContentResultSetStubFactory.idl\
- XCachedDynamicResultSetFactory.idl\
- XCachedDynamicResultSetStubFactory.idl\
- XCommandEnvironment.idl\
- XCommandInfo.idl\
- XCommandInfoChangeListener.idl\
- XCommandInfoChangeNotifier.idl\
- XCommandProcessor.idl\
- XCommandProcessor2.idl\
- XContent.idl\
- XContentAccess.idl\
- XContentCreator.idl\
- XContentEventListener.idl\
- XContentIdentifier.idl\
- XContentIdentifierFactory.idl\
- XContentIdentifierMapping.idl\
- XContentProvider.idl\
- XContentProviderFactory.idl\
- XContentProviderManager.idl\
- XContentProviderSupplier.idl\
- XContentTransmitter.idl\
- XDataContainer.idl\
- XDynamicResultSet.idl\
- XDynamicResultSetListener.idl\
- XFetchProvider.idl\
- XFetchProviderForContentAccess.idl\
- XFileIdentifierConverter.idl\
- XInteractionCookieHandling.idl\
- XInteractionHandlerSupplier.idl\
- XInteractionReplaceExistingData.idl\
- XInteractionSupplyAuthentication.idl\
- XInteractionSupplyName.idl\
- XParameterizedContentProvider.idl\
- XPersistentPropertySet.idl\
- XProgressHandler.idl\
- XPropertyMatcher.idl\
- XPropertyMatcherFactory.idl\
- XPropertySetRegistry.idl\
- XPropertySetRegistryFactory.idl\
- XRecycler.idl\
- XRemoteContentProviderAcceptor.idl\
- XRemoteContentProviderActivator.idl\
- XRemoteContentProviderChangeListener.idl\
- XRemoteContentProviderChangeNotifier.idl\
- XRemoteContentProviderConnectionControl.idl\
- XRemoteContentProviderDistributor.idl\
- XRemoteContentProviderDoneListener.idl\
- XRemoteContentProviderSupplier.idl\
- XSimpleFileAccess.idl\
- XSimpleFileAccess2.idl\
- XSimpleFileAccess3.idl\
- XSortedDynamicResultSetFactory.idl\
+ UniversalContentBroker.idl\
+ UnsupportedCommandException.idl\
+ UnsupportedDataSinkException.idl\
+ UnsupportedNameClashException.idl\
+ UnsupportedOpenModeException.idl\
+ VerificationMode.idl\
+ WebDAVContentProvider.idl\
+ WebDAVDocumentContent.idl\
+ WebDAVFolderContent.idl\
+ WelcomeDynamicResultSetStruct.idl\
+ XAnyCompare.idl\
+ XAnyCompareFactory.idl\
+ XCachedContentResultSetFactory.idl\
+ XCachedContentResultSetStubFactory.idl\
+ XCachedDynamicResultSetFactory.idl\
+ XCachedDynamicResultSetStubFactory.idl\
+ XCommandEnvironment.idl\
+ XCommandInfo.idl\
+ XCommandInfoChangeListener.idl\
+ XCommandInfoChangeNotifier.idl\
+ XCommandProcessor.idl\
+ XCommandProcessor2.idl\
+ XContent.idl\
+ XContentAccess.idl\
+ XContentCreator.idl\
+ XContentEventListener.idl\
+ XContentIdentifier.idl\
+ XContentIdentifierFactory.idl\
+ XContentIdentifierMapping.idl\
+ XContentProvider.idl\
+ XContentProviderFactory.idl\
+ XContentProviderManager.idl\
+ XContentProviderSupplier.idl\
+ XContentTransmitter.idl\
+ XDataContainer.idl\
+ XDynamicResultSet.idl\
+ XDynamicResultSetListener.idl\
+ XFetchProvider.idl\
+ XFetchProviderForContentAccess.idl\
+ XFileIdentifierConverter.idl\
+ XInteractionCookieHandling.idl\
+ XInteractionHandlerSupplier.idl\
+ XInteractionReplaceExistingData.idl\
+ XInteractionSupplyAuthentication.idl\
+ XInteractionSupplyAuthentication2.idl\
+ XInteractionSupplyName.idl\
+ XParameterizedContentProvider.idl\
+ XPersistentPropertySet.idl\
+ XProgressHandler.idl\
+ XPropertyMatcher.idl\
+ XPropertyMatcherFactory.idl\
+ XPropertySetRegistry.idl\
+ XPropertySetRegistryFactory.idl\
+ XRecycler.idl\
+ XRemoteContentProviderAcceptor.idl\
+ XRemoteContentProviderActivator.idl\
+ XRemoteContentProviderChangeListener.idl\
+ XRemoteContentProviderChangeNotifier.idl\
+ XRemoteContentProviderConnectionControl.idl\
+ XRemoteContentProviderDistributor.idl\
+ XRemoteContentProviderDoneListener.idl\
+ XRemoteContentProviderSupplier.idl\
+ XSimpleFileAccess.idl\
+ XSimpleFileAccess2.idl\
+ XSimpleFileAccess3.idl\
+ XSortedDynamicResultSetFactory.idl\
XSourceInitialization.idl\
XWebDAVCommandEnvironment.idl \
CertificateValidationRequest.idl
diff --git a/offapi/prj/build.lst b/offapi/prj/build.lst
index 6b4a0b95a054..6ddea0190596 100644
--- a/offapi/prj/build.lst
+++ b/offapi/prj/build.lst
@@ -103,5 +103,6 @@ oa offapi\com\sun\star\xml\wrapper nmake - all oa_wrapper oa_sax NULL
oa offapi\com\sun\star\geometry nmake - all oa_geometry NULL
oa offapi\com\sun\star\rendering nmake - all oa_rendering oa_geometry NULL
oa offapi\com\sun\star\rdf nmake - all oa_rdf oa_datatransfer oa_text NULL
+oa offapi\com\sun\star\office nmake - all oa_office oa_text NULL
oa offapi\drafts\com\sun\star\form nmake - all oa_drafts_form NULL
-oa offapi\util nmake - all oa_util oa_auth oa_awt oa_awttree oa_awtgrid oa_chart oa_chart2 oa_chart2_data oa_config oa_configbootstrap oa_configbackend oa_configbackend_xml oa_datatrans_clip oa_datatrans_dnd oa_datatransfer oa_docu oa_draw oa_draw_framework oa_embed oa_fcomp oa_finsp oa_fcontr oa_fieldmaster oa_form oa_xforms oa_formula oa_frame oa_i18n oa_inst oa_ldap oa_ling2 oa_logging oa_mail oa_media oa_mozilla oa_packages oa_manifest oa_zippackage oa_plug oa_pres oa_animations oa_putil oa_resrc oa_sax oa_xml_input oa_scan oa_sdb oa_sdbtools oa_sdbapp oa_sdbc oa_sdbcx oa_setup oa_sheet oa_style oa_svg oa_sync oa_sync2 oa_system oa_table oa_task oa_text oa_textfield oa_docinfo oa_ucb oa_view oa_xml oa_xml_dom oa_xml_xpath oa_xml_views oa_xml_events oa_image oa_xsd oa_inspection oa_ui oa_ui_dialogs oa_accessibility oa_form_binding oa_form_validation oa_form_submission oa_fruntime oa_geometry oa_rendering oa_sfprovider oa_sfbrowse oa_drafts_form oa_deployment oa_deploymenttest oa_deployment_ui oa_frame_status oa_gallery oa_graphic oa_security oa_crypto_sax oa_crypto oa_csax oa_wrapper oa_script oa_smarttags oa_report oa_reportins oa_reportmeta oa_rdf oa_oooimprovement NULL
+oa offapi\util nmake - all oa_util oa_auth oa_awt oa_awttree oa_awtgrid oa_chart oa_chart2 oa_chart2_data oa_config oa_configbootstrap oa_configbackend oa_configbackend_xml oa_datatrans_clip oa_datatrans_dnd oa_datatransfer oa_docu oa_draw oa_draw_framework oa_embed oa_fcomp oa_finsp oa_fcontr oa_fieldmaster oa_form oa_xforms oa_formula oa_frame oa_i18n oa_inst oa_ldap oa_ling2 oa_logging oa_mail oa_media oa_mozilla oa_packages oa_manifest oa_zippackage oa_plug oa_pres oa_animations oa_putil oa_resrc oa_sax oa_xml_input oa_scan oa_sdb oa_sdbtools oa_sdbapp oa_sdbc oa_sdbcx oa_setup oa_sheet oa_style oa_svg oa_sync oa_sync2 oa_system oa_table oa_task oa_text oa_textfield oa_docinfo oa_ucb oa_view oa_xml oa_xml_dom oa_xml_xpath oa_xml_views oa_xml_events oa_image oa_xsd oa_inspection oa_ui oa_ui_dialogs oa_accessibility oa_form_binding oa_form_validation oa_form_submission oa_fruntime oa_geometry oa_rendering oa_sfprovider oa_sfbrowse oa_drafts_form oa_deployment oa_deploymenttest oa_deployment_ui oa_frame_status oa_gallery oa_graphic oa_security oa_crypto_sax oa_crypto oa_csax oa_wrapper oa_script oa_smarttags oa_report oa_reportins oa_reportmeta oa_rdf oa_oooimprovement oa_office NULL
diff --git a/offapi/util/makefile.mk b/offapi/util/makefile.mk
index fcf3e4bd6c02..b0fa7a30cf46 100644
--- a/offapi/util/makefile.mk
+++ b/offapi/util/makefile.mk
@@ -144,6 +144,7 @@ UNOIDLDBFILES= \
$(UCR)$/cssreport.db \
$(UCR)$/cssrptins.db \
$(UCR)$/cssrptmeta.db \
+ $(UCR)$/cssoffice.db \
$(UCR)$/cssrdf.db
diff --git a/offuh/prj/d.lst b/offuh/prj/d.lst
index 0e85b261e8e2..bedbc8d112d4 100644
--- a/offuh/prj/d.lst
+++ b/offuh/prj/d.lst
@@ -51,6 +51,7 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\lang
mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\linguistic2
mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\logging
mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\oooimprovement
+mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\office
mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\mail
mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\media
mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\packages
@@ -226,6 +227,8 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf
..\%__SRC%\inc\offuh\com\sun\star\linguistic2\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\linguistic2\*.hpp
..\%__SRC%\inc\offuh\com\sun\star\logging\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\logging\*.hdl
..\%__SRC%\inc\offuh\com\sun\star\logging\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\logging\*.hpp
+..\%__SRC%\inc\offuh\com\sun\star\office\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\office\*.hpp
+..\%__SRC%\inc\offuh\com\sun\star\office\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\office\*.hdl
..\%__SRC%\inc\offuh\com\sun\star\oooimprovement\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\oooimprovement\*.hdl
..\%__SRC%\inc\offuh\com\sun\star\oooimprovement\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\oooimprovement\*.hpp
..\%__SRC%\inc\offuh\com\sun\star\mail\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\mail\*.hpp
@@ -371,4 +374,3 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf
..\%__SRC%\inc\offuh\com\sun\star\rdf\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf\*.hpp
..\%__SRC%\inc\offuh\com\sun\star\rdf\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf\*.hdl
-
diff --git a/pyuno/prj/d.lst b/pyuno/prj/d.lst
index 16631ada6fbd..5fe7400a8d58 100644
--- a/pyuno/prj/d.lst
+++ b/pyuno/prj/d.lst
@@ -16,6 +16,7 @@ mkdir: %_DEST%\lib%_EXT%\pyuno
..\%__SRC%\bin\uno.py %_DEST%\bin%_EXT%\pyuno\uno.py
..\%__SRC%\bin\pyuno_services.rdb %_DEST%\bin%_EXT%\pyuno_services.rdb
..\%__SRC%\bin\pyuno.pyd %_DEST%\bin%_EXT%\pyuno.pyd
+..\%__SRC%\bin\pyuno.dll %_DEST%\bin%_EXT%\pyuno.dll
..\%__SRC%\bin\pythonl*.dll %_DEST%\bin%_EXT%\pythonl*.dll
..\%__SRC%\misc\pyunorc %_DEST%\lib%_EXT%\pyunorc
diff --git a/pyuno/source/loader/makefile.mk b/pyuno/source/loader/makefile.mk
index 11ece4796301..6e4f96ed7014 100644
--- a/pyuno/source/loader/makefile.mk
+++ b/pyuno/source/loader/makefile.mk
@@ -37,7 +37,7 @@ ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
-
+.IF "$(L10N_framework)"==""
DLLPRE =
#-------------------------------------------------------------------
@@ -101,18 +101,16 @@ COMPONENTS= \
ALL : ALLTAR \
$(DLLDEST)$/pythonloader.py \
$(DLLDEST)$/pyuno_services.rdb
+.ENDIF # L10N_framework
.INCLUDE : target.mk
-
+.IF "$(L10N_framework)"==""
$(DLLDEST)$/%.py: %.py
cp $? $@
$(DLLDEST)$/pyuno_services.rdb : makefile.mk $(DLLDEST)$/$(DLLPRE)$(TARGET)$(DLLPOST)
-rm -f $@ $(DLLDEST)$/pyuno_services.tmp $(DLLDEST)$/pyuno_services.rdb
-.IF "$(GUI)$(COM)"=="WNTGCC"
- cd $(DLLDEST) && sh -c "export PATH='$(PATH):$(OUT)$/bin'; $(REGCOMP) -register -r pyuno_services.tmp -wop $(foreach,i,$(COMPONENTS) -c $(i))"
-.ELSE
cd $(DLLDEST) && $(REGCOMP) -register -r pyuno_services.tmp -wop $(foreach,i,$(COMPONENTS) -c $(i))
-.ENDIF # "$(GUI)$(COM)"=="WNTGCC"
cd $(DLLDEST) && mv pyuno_services.tmp pyuno_services.rdb
+.ENDIF # L10N_framework
diff --git a/pyuno/source/module/makefile.mk b/pyuno/source/module/makefile.mk
index 94de195e750f..2357d0062ed0 100644
--- a/pyuno/source/module/makefile.mk
+++ b/pyuno/source/module/makefile.mk
@@ -39,6 +39,7 @@ LINKFLAGSDEFS = # do not fail with missing symbols
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
#-------------------------------------------------------------------
.IF "$(OS)$(CPU)$(COMEX)" == "SOLARISS4"
@@ -56,6 +57,9 @@ EXTRA_FRAMEWORK_FLAG=-framework Python
# pyuno.so even on Mac OS X, because it is a python module
PYUNO_MODULE=$(DLLDEST)$/pyuno.so
PYUNORC=pyunorc
+.ELIF "$(GUI)" == "OS2"
+.INCLUDE : pyversion.mk
+PYUNORC=pyuno.ini
.ELSE
.INCLUDE : pyversion.mk
PYUNORC=pyuno.ini
@@ -125,10 +129,11 @@ ALLTAR : \
$(DLLDEST)$/unohelper.py \
$(PYUNO_MODULE) \
$(MISC)$/$(PYUNORC)
+.ENDIF
.ENDIF
.INCLUDE : target.mk
-
+.IF "$(L10N_framework)"==""
$(DLLDEST)$/%.py: %.py
cp $? $@
@@ -160,4 +165,5 @@ $(MISC)$/$(PYUNORC) : pyuno
$(MISC)$/pyuno.flt : pyuno.flt
-rm -f $@
cat $? > $@
+.ENDIF # L10N_framework
diff --git a/pyuno/zipcore/makefile.mk b/pyuno/zipcore/makefile.mk
index f46106dc8afe..a820c1a59f4f 100755
--- a/pyuno/zipcore/makefile.mk
+++ b/pyuno/zipcore/makefile.mk
@@ -36,7 +36,7 @@ TARGET=zipcore
LIBTARGET=NO
.INCLUDE : settings.mk
-
+.IF "$(L10N_framework)"==""
UWINAPILIB =
.IF "$(SYSTEM_PYTHON)" == "YES" || "$(GUI)" == "OS2"
@@ -74,6 +74,7 @@ APP1RPATH = BRAND
OBJFILES = $(OBJ)$/python.obj
.ENDIF
+
.INCLUDE: target.mk
ALLTAR: \
@@ -129,3 +130,7 @@ $(DESTROOT)$/bin$/python$(EXECPOST) : $(SOLARBINDIR)$/python$(EXECPOST)
.ENDIF
.ENDIF
+.ELSE
+ivo:
+ $(ECHO)
+.ENDIF # L10N_framework
diff --git a/remotebridges/source/bridge/makefile.mk b/remotebridges/source/bridge/makefile.mk
index ef02b1bcebc9..75b5f3a6152e 100644
--- a/remotebridges/source/bridge/makefile.mk
+++ b/remotebridges/source/bridge/makefile.mk
@@ -38,6 +38,7 @@ COMP1TYPELIST = remotebridge
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
DLLPRE =
# ------------------------------------------------------------------
@@ -61,6 +62,7 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def
SHL1RPATH= URELIB
DEF1NAME= $(SHL1TARGET)
+.ENDIF # L10N_framework
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
diff --git a/remotebridges/source/dynamicloader/makefile.mk b/remotebridges/source/dynamicloader/makefile.mk
index 1a4364c74062..95a80e107ffb 100755
--- a/remotebridges/source/dynamicloader/makefile.mk
+++ b/remotebridges/source/dynamicloader/makefile.mk
@@ -39,6 +39,7 @@ COMP1TYPELIST = dynamicloader
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
DLLPRE =
# ------------------------------------------------------------------
@@ -65,6 +66,7 @@ SHL1DEF=$(MISC)$/$(SHL1TARGET).def
DEF1NAME= $(SHL1TARGET)
+.ENDIF # L10N_framework
# --- Targets ------------------------------------------------------
diff --git a/remotebridges/source/factory/makefile.mk b/remotebridges/source/factory/makefile.mk
index 280ed38829f8..97eb02415a47 100644
--- a/remotebridges/source/factory/makefile.mk
+++ b/remotebridges/source/factory/makefile.mk
@@ -38,6 +38,7 @@ COMP1TYPELIST = brdgfctr
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
DLLPRE =
# ------------------------------------------------------------------
@@ -61,6 +62,7 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def
SHL1RPATH= URELIB
DEF1NAME= $(SHL1TARGET)
+.ENDIF # L10N_framework
# --- Targets ------------------------------------------------------
diff --git a/remotebridges/source/unourl_resolver/makefile.mk b/remotebridges/source/unourl_resolver/makefile.mk
index bb005dc167c4..81f8b1c67609 100644
--- a/remotebridges/source/unourl_resolver/makefile.mk
+++ b/remotebridges/source/unourl_resolver/makefile.mk
@@ -38,6 +38,7 @@ COMP1TYPELIST = uuresolver
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
+.IF "$(L10N_framework)"==""
DLLPRE =
# ------------------------------------------------------------------
@@ -60,6 +61,7 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def
SHL1RPATH= URELIB
DEF1NAME= $(SHL1TARGET)
+.ENDIF # L10N_framework
# --- Targets ------------------------------------------------------
diff --git a/ridljar/com/sun/star/uno/UnoRuntime.java b/ridljar/com/sun/star/uno/UnoRuntime.java
index dcf7ff42b10c..28ee8fb1e2bd 100644
--- a/ridljar/com/sun/star/uno/UnoRuntime.java
+++ b/ridljar/com/sun/star/uno/UnoRuntime.java
@@ -179,8 +179,9 @@ public class UnoRuntime {
* otherwise <code>null</code>
* @see #queryInterface(Type, Object)
*/
- public static Object queryInterface(Class zInterface, Object object) {
- return queryInterface(new Type(zInterface), object);
+ @SuppressWarnings("unchecked")
+ public static <T> T queryInterface(Class<T> zInterface, Object object) {
+ return (T) queryInterface(new Type(zInterface), object);
}
/**
diff --git a/ridljar/test/com/sun/star/uno/UnoRuntime_Test.java b/ridljar/test/com/sun/star/uno/UnoRuntime_Test.java
index 06af7828039e..a9eef19b0a64 100644
--- a/ridljar/test/com/sun/star/uno/UnoRuntime_Test.java
+++ b/ridljar/test/com/sun/star/uno/UnoRuntime_Test.java
@@ -54,7 +54,7 @@ public final class UnoRuntime_Test extends ComplexTestCase {
// Test if a delegator object has the same OID as its creator:
Test4 test4 = new Test4();
- Ifc ifc = (Ifc) UnoRuntime.queryInterface(Ifc.class, test4);
+ Ifc ifc = UnoRuntime.queryInterface(Ifc.class, test4);
assure(
"Test4",
UnoRuntime.generateOid(test4).equals(UnoRuntime.generateOid(ifc)));
@@ -64,19 +64,19 @@ public final class UnoRuntime_Test extends ComplexTestCase {
// Test if a query for an interface which is not supported returns null:
assure(
"Test1",
- (Ifc) UnoRuntime.queryInterface(Ifc.class, new Test1()) == null);
+ UnoRuntime.queryInterface(Ifc.class, new Test1()) == null);
// Test if a query for an interface which is supported through
// IQueryInterface succeeds:
assure(
"Test2",
- (Ifc) UnoRuntime.queryInterface(Ifc.class, new Test2()) != null);
+ UnoRuntime.queryInterface(Ifc.class, new Test2()) != null);
// Test if a query for an interface which is directly supported (through
// inheritance) succeeds:
assure(
"Test3",
- (Ifc) UnoRuntime.queryInterface(Ifc.class, new Test3()) != null);
+ UnoRuntime.queryInterface(Ifc.class, new Test3()) != null);
}
public void test_areSame() {
diff --git a/sal/inc/rtl/math.h b/sal/inc/rtl/math.h
index 4d72bcaa39d1..fed06e511b26 100644
--- a/sal/inc/rtl/math.h
+++ b/sal/inc/rtl/math.h
@@ -434,6 +434,42 @@ double SAL_CALL rtl_math_log1p(double fValue) SAL_THROW_EXTERN_C();
*/
double SAL_CALL rtl_math_atanh(double fValue) SAL_THROW_EXTERN_C();
+/** Returns values of the Errorfunction erf.
+
+ erf is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term erf(x).
+ */
+double SAL_CALL rtl_math_erf(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns values of the complement Errorfunction erfc.
+
+ erfc is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term erfc(x).
+ */
+double SAL_CALL rtl_math_erfc(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns values of the inverse hyperbolic sine.
+
+ asinh is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term asinh(x).
+ */
+double SAL_CALL rtl_math_asinh(double fValue) SAL_THROW_EXTERN_C();
+
+/** Returns values of the inverse hyperbolic cosine.
+
+ acosh is part of the C99 standard, but not provided by some compilers.
+
+ @param fValue
+ The value x in the term acosh(x).
+ */
+double SAL_CALL rtl_math_acosh(double fValue) SAL_THROW_EXTERN_C();
+
#if defined __cplusplus
}
#endif /* __cplusplus */
diff --git a/sal/inc/rtl/math.hxx b/sal/inc/rtl/math.hxx
index b61cf9b9806f..5760340cc6a4 100644
--- a/sal/inc/rtl/math.hxx
+++ b/sal/inc/rtl/math.hxx
@@ -221,6 +221,35 @@ inline double atanh(double fValue)
return rtl_math_atanh(fValue);
}
+/** A wrapper around rtl_math_erf.
+ */
+inline double erf(double fValue)
+{
+ return rtl_math_erf(fValue);
+}
+
+/** A wrapper around rtl_math_erfc.
+ */
+inline double erfc(double fValue)
+{
+ return rtl_math_erfc(fValue);
+}
+
+/** A wrapper around rtl_math_asinh.
+ */
+inline double asinh(double fValue)
+{
+ return rtl_math_asinh(fValue);
+}
+
+/** A wrapper around rtl_math_acosh.
+ */
+inline double acosh(double fValue)
+{
+ return rtl_math_acosh(fValue);
+}
+
+
/** Test equality of two values with an accuracy of the magnitude of the
given values scaled by 2^-48 (4 bits roundoff stripped).
diff --git a/sal/inc/sal/types.h b/sal/inc/sal/types.h
index 23c7529eed26..eec07286f2c5 100644
--- a/sal/inc/sal/types.h
+++ b/sal/inc/sal/types.h
@@ -124,10 +124,17 @@ typedef unsigned char sal_uInt8;
#define SAL_CONST_INT64(x) x##ll
#define SAL_CONST_UINT64(x) x##ull
+ #ifdef __MINGW32__
+ #define SAL_PRIdINT64 "I64d"
+ #define SAL_PRIuUINT64 "I64u"
+ #define SAL_PRIxUINT64 "I64x"
+ #define SAL_PRIXUINT64 "I64X"
+ #else
#define SAL_PRIdINT64 "lld"
#define SAL_PRIuUINT64 "llu"
#define SAL_PRIxUINT64 "llx"
#define SAL_PRIXUINT64 "llX"
+ #endif
#else
#error "Could not find 64-bit type, add support for your architecture"
#endif
@@ -170,7 +177,7 @@ typedef void * sal_Handle;
/* printf-style conversion specification length modifiers for size_t and
ptrdiff_t (most platforms support C99, MSC has its own extension) */
-#if defined _MSC_VER
+#if defined(_MSC_VER) || defined(__MINGW32__)
#define SAL_PRI_SIZET "I"
#define SAL_PRI_PTRDIFFT "I"
#else
diff --git a/sal/osl/all/makefile.mk b/sal/osl/all/makefile.mk
index 6bed1c53cfaa..bbb46b89d44e 100644
--- a/sal/osl/all/makefile.mk
+++ b/sal/osl/all/makefile.mk
@@ -57,18 +57,20 @@ CXXFLAGS+= $(LFS_CFLAGS)
SLOFILES= \
$(SLO)$/utility.obj\
- $(SLO)$/readline.obj\
$(SLO)$/filepath.obj\
$(SLO)$/debugbase.obj\
$(SLO)$/loadmodulerelative.obj
+# $(SLO)$/readline.obj\
+
#.IF "$(UPDATER)"=="YES"
OBJFILES= \
$(OBJ)$/utility.obj\
- $(OBJ)$/readline.obj\
$(OBJ)$/filepath.obj\
$(OBJ)$/debugbase.obj\
$(OBJ)$/loadmodulerelative.obj
+
+# $(OBJ)$/readline.obj\
#.ENDIF
# --- Targets ------------------------------------------------------
diff --git a/sal/osl/all/readline.c b/sal/osl/all/readline.c
deleted file mode 100644
index 9fc4bced83aa..000000000000
--- a/sal/osl/all/readline.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: readline.c,v $
- * $Revision: 1.9 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include <osl/diagnose.h>
-#include <osl/file.h>
-#include <rtl/byteseq.h>
-#include <rtl/alloc.h>
-
-
-/* Test cases:
-
- 1. A file without line ends
- 2. A file with lines longer than the initial buffer size
- 3. An empty file
- 4.
-*/
-
-/** Some defines
-*/
-#define CR 0x0D
-#define LF 0x0A
-
-#define INITIAL_BUFF_SIZE 80
-#define BUFFER_GROW_FACTOR 2
-#define READ_BLOCK_SIZE (INITIAL_BUFF_SIZE - 1)
-
-/** Helper data and function
-*/
-
-struct _Buffer
-{
- sal_Char* m_pMem;
- sal_uInt64 m_Capacity; /* elements possible in buffer */
- sal_uInt64 m_Size; /* elements actually in buffer */
- sal_uInt64 m_ActiveSectionStart; /* buffer was lastly filled from here to
- (m_Size - 1) */
-};
-
-typedef struct _Buffer Buffer;
-
-
-/** Allocate the memory of the buffer
- @Returns sal_True on succes
-*/
-static sal_Bool AllocateBuffer(Buffer* pBuffer, sal_uInt64 Capacity)
-{
- sal_Bool rc = sal_False;
-
- OSL_ASSERT(pBuffer);
-
- pBuffer->m_pMem = (sal_Char*)rtl_allocateZeroMemory((sal_uInt32)Capacity);
- if (pBuffer->m_pMem)
- {
- pBuffer->m_Capacity = Capacity;
- pBuffer->m_Size = 0;
- pBuffer->m_ActiveSectionStart = 0;
- rc = sal_True;
- }
-
- return rc;
-}
-
-/** Release the memory occupied by the buffer
-*/
-static void FreeBuffer(Buffer* pBuffer)
-{
- OSL_ASSERT(pBuffer);
-
- rtl_freeMemory(pBuffer->m_pMem);
- pBuffer->m_pMem = 0;
- pBuffer->m_Capacity = 0;
- pBuffer->m_Size = 0;
- pBuffer->m_ActiveSectionStart = 0;
-}
-
-/** Grow the buffer by the specified factor (usually doubling
- the buffer size)
- In case of failure, growing the buffer, the original buffer
- stays untouched
-
- @Returns sal_True on success
-*/
-static sal_Bool GrowBuffer(Buffer* pBuffer, size_t factor)
-{
- sal_Bool rc = sal_False;
- void* p;
-
- OSL_ASSERT(pBuffer);
-
- p = rtl_reallocateMemory(
- pBuffer->m_pMem, (sal_uInt32)(pBuffer->m_Capacity * factor));
- if (p)
- {
- pBuffer->m_pMem = (sal_Char*)p;
- pBuffer->m_Capacity *= factor;
- rc = sal_True;
- }
-
- return rc;
-}
-
-/** Read n bytes from file into buffer,
- grow the buffer if necessary
-
- @Returns osl_File_E_None on success else
- an error code
-*/
-static oslFileError ReadFromFile(oslFileHandle hFile, Buffer* pBuffer, sal_uInt64 Requested, sal_uInt64* pRead)
-{
- oslFileError rc;
-
- OSL_ASSERT(pBuffer);
- OSL_ASSERT(hFile);
- OSL_ASSERT(pRead);
-
- if (((pBuffer->m_Size + Requested) > pBuffer->m_Capacity) &&
- !GrowBuffer(pBuffer, BUFFER_GROW_FACTOR))
- return osl_File_E_NOMEM;
-
- pBuffer->m_ActiveSectionStart = pBuffer->m_Size;
-
- rc = osl_readFile(
- hFile,
- pBuffer->m_pMem + pBuffer->m_ActiveSectionStart,
- Requested,
- pRead);
-
- if (osl_File_E_None == rc)
- pBuffer->m_Size += *pRead;
-
- return rc;
-}
-
-/** Makes a sequence from the given buffer and release the memory
- occupied by the buffer
-*/
-static void MakeSequenceFreeBuffer(sal_Sequence** ppSequence, Buffer* pBuffer, sal_uInt64 Length)
-{
- OSL_ASSERT(ppSequence);
- OSL_ASSERT(pBuffer);
- OSL_ASSERT(Length <= pBuffer->m_Capacity);
-
- rtl_byte_sequence_constructFromArray(ppSequence, (sal_Int8*)pBuffer->m_pMem, (sal_Int32)Length);
- FreeBuffer(pBuffer);
-}
-
-/** Handle occurence of LF character:
- construct a sequence from buffer
- correct file pointer (maybe we have read more than necessary)
-
- @Returns osl_File_E_None on success else
- an error code
-*/
-static oslFileError HandleLFFreeBuffer(oslFileHandle hFile, sal_Sequence** ppSequence, Buffer* pBuffer, sal_uInt64 Pos)
-{
- sal_Int64 offset = 0;
- oslFileError rc = osl_File_E_None;
-
- OSL_ASSERT(hFile);
- OSL_ASSERT(pBuffer);
- OSL_ASSERT(LF == pBuffer->m_pMem[Pos]);
-
- /* correct file pointer pos in case we have read to far */
- offset = pBuffer->m_Size - (Pos + 1);
- rc = osl_setFilePos(hFile, osl_Pos_Current, -offset);
-
- if (osl_File_E_None == rc)
- MakeSequenceFreeBuffer(ppSequence, pBuffer, Pos);
- else
- FreeBuffer(pBuffer);
-
- return rc;
-}
-
-/** Handle occurence of CR character
- construct a sequence from buffer
- correct file pointer (maybe we have read more than necessary)
-
- @Returns osl_File_E_None on success else
- an error code
-*/
-static oslFileError HandleCRFreeBuffer(oslFileHandle hFile, sal_Sequence** ppSequence, Buffer* pBuffer, sal_uInt64 Pos)
-{
- sal_Int64 offset = 0;
- sal_uInt64 nread = 0;
- oslFileError rc = osl_File_E_None;
-
- OSL_ASSERT(hFile);
- OSL_ASSERT(pBuffer);
- OSL_ASSERT(CR == pBuffer->m_pMem[Pos]);
-
- if (Pos == (pBuffer->m_Size - 1))
- {
- /* only need to check if the next byte is a LF
- that's why reading only one byte from file */
- rc = ReadFromFile(hFile, pBuffer, 1, &nread);
-
- if (osl_File_E_None != rc)
- {
- FreeBuffer(pBuffer);
- return rc;
- }
- else if (0 == nread)
- {
- MakeSequenceFreeBuffer(ppSequence, pBuffer, Pos);
- return osl_File_E_None;
- }
- }
-
- if (LF == pBuffer->m_pMem[Pos + 1])
- Pos++;
-
- /* correct the file pointer */
- offset = pBuffer->m_Size - (Pos + 1);
- rc = osl_setFilePos(hFile, osl_Pos_Current, -offset);
-
- if (osl_File_E_None == rc)
- MakeSequenceFreeBuffer(ppSequence, pBuffer, Pos - 1);
- else
- FreeBuffer(pBuffer);
-
- return rc;
-}
-
-/***************************************************************************
- osl_readLine (platform independent)
- Reads a line from given file. The new line delimiter(s) are NOT returned!
- Valid line ends: \n, \r\n or \r
-
- @param Handle [in] Handle to an open file.
- @param ppSequence [in/out] a pointer to a valid sequence.
-
- @return osl_File_E_None on success otherwise one of the following errorcodes:<p>
-
- osl_File_E_INVAL the format of the parameters was not valid<br>
- osl_File_E_NOMEM the necessary memory could not be allocated
-****************************************************************************/
-
-oslFileError SAL_CALL osl_readLine(oslFileHandle Handle, sal_Sequence** ppSeq)
-{
- oslFileError rc;
- sal_uInt64 nread = 0;
- Buffer line_buffer;
- sal_uInt64 pos;
-
- OSL_PRECOND(Handle, "invalid handle");
- OSL_PRECOND(ppSeq, "invalid parameter detected");
-
- if (!AllocateBuffer(&line_buffer, INITIAL_BUFF_SIZE))
- return osl_File_E_NOMEM;
-
- for(;;)
- {
- rc = ReadFromFile(Handle, &line_buffer, READ_BLOCK_SIZE, &nread);
-
- if (osl_File_E_None != rc)
- {
- FreeBuffer(&line_buffer);
- return rc;
- }
- else if (0 == nread)
- {
- /* EOF */
- nread = line_buffer.m_Size;
- MakeSequenceFreeBuffer(ppSeq, &line_buffer, nread);
- if (0 < nread)
- return osl_File_E_None;
- else
- return osl_File_E_AGAIN;
- }
-
- /* scan buffer for line end */
- for (pos = line_buffer.m_ActiveSectionStart; pos < line_buffer.m_Size; pos++)
- {
- switch(line_buffer.m_pMem[pos])
- {
- case LF:
- return HandleLFFreeBuffer(Handle, ppSeq, &line_buffer, pos);
- case CR:
- return HandleCRFreeBuffer(Handle, ppSeq, &line_buffer, pos);
- }
- }
- } /* end for */
-}
diff --git a/sal/osl/os2/debug.c b/sal/osl/os2/debug.c
index 67fc7a1e709f..78a2df07056e 100644
--- a/sal/osl/os2/debug.c
+++ b/sal/osl/os2/debug.c
@@ -1,3 +1,33 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:$
+ * $Revision:$
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
/*
*@@sourcefile debug.c:
* this file contains debugging functions for the
@@ -27,20 +57,15 @@
*/
/*
- * This file Copyright (C) 1992-99 Ulrich Mller,
+ * This file Copyright (C) 1992-99 Ulrich M�ller,
* Kim Rasmussen,
* Marc Fiammante,
* John Currier,
* Anthony Cruise.
* This file is part of the "XWorkplace helpers" source package.
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation, in version 2 as it comes in the
- * "COPYING" file of the XWorkplace main distribution.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ *
+ * 2009-06-15 published under LGPL3 with Ulrich M�ller permission.
+ *
*/
//#define DEBUG_SYMDUMP // enable to dump sym file to log
@@ -1484,7 +1509,7 @@ void dbgPrintVariables(FILE *LogFile, // in: text log file to write to
(PVOID)stackofs,
func_name);
fprintf(LogFile, " Offset Name Type Value \n");
- fprintf(LogFile, " \n");
+ fprintf(LogFile, " ������ �������������������� ��������������������������������� �����������������\n");
}
// If it's one of the simple types
@@ -1880,7 +1905,7 @@ VOID dbgPrintStack(FILE *LogFile, // in: text log file to write to
fprintf(LogFile, "\n\nCall stack:\n");
fprintf(LogFile, " Source Line Nearest\n");
fprintf(LogFile, " EBP Address Module Obj# File Numbr Public Symbol\n");
- fprintf(LogFile, " - -\n");
+ fprintf(LogFile, " �������� ��������- �������� ���� ������������ ����� ������������-\n");
do
{
diff --git a/sal/osl/os2/except.c b/sal/osl/os2/except.c
index e1ae9fb7bd06..0dd2a35d1fcd 100644
--- a/sal/osl/os2/except.c
+++ b/sal/osl/os2/except.c
@@ -1,3 +1,32 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:$
+ * $Revision:$
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
/*
*@@sourcefile except.c:
@@ -178,7 +207,7 @@
* exception handling DLL, available at Hobbes).
*
* If not explicitly stated otherwise, the code has been written
- * by me, Ulrich Mller.
+ * by me, Ulrich M�ller.
*
* Note: Version numbering in this file relates to XWorkplace version
* numbering.
@@ -187,7 +216,7 @@
*/
/*
- * This file Copyright (C) 1992-99 Ulrich Mller,
+ * This file Copyright (C) 1992-99 Ulrich M�ller,
* Monte Copeland,
* Roman Stangl,
* Kim Rasmussen,
@@ -195,14 +224,9 @@
* John Currier,
* Anthony Cruise.
* This file is part of the "XWorkplace helpers" source package.
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation, in version 2 as it comes in the
- * "COPYING" file of the XWorkplace main distribution.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ *
+ * 2009-06-15 published under LGPL3 with Ulrich M�ller permission.
+ *
*/
#define OS2EMX_PLAIN_CHAR
diff --git a/sal/osl/os2/helpers/debug.h b/sal/osl/os2/helpers/debug.h
index be35be3d3326..b03508b70379 100644
--- a/sal/osl/os2/helpers/debug.h
+++ b/sal/osl/os2/helpers/debug.h
@@ -1,3 +1,32 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:$
+ * $Revision:$
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
/*
*@@sourcefile debug.h:
@@ -21,19 +50,14 @@
* Anthony Cruise (EXCEPT3.ZIP package for a generic
* exception handling DLL, available at Hobbes).
*
- * This file Copyright (C) 1992-99 Ulrich Mller,
+ * This file Copyright (C) 1992-99 Ulrich M�ller,
* Kim Rasmussen,
* Marc Fiammante,
* John Currier,
* Anthony Cruise.
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, in version 2 as it comes in the COPYING
- * file of the XFolder main distribution.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ *
+ * 2009-06-15 published under LGPL3 with Ulrich M�ller permission.
+ *
*/
#ifndef DEBUG_HEADER_INCLUDED
diff --git a/sal/osl/os2/helpers/dosh.h b/sal/osl/os2/helpers/dosh.h
index d2e936a57447..518f979fd4de 100644
--- a/sal/osl/os2/helpers/dosh.h
+++ b/sal/osl/os2/helpers/dosh.h
@@ -1,28 +1,39 @@
-
-/*
- *@@sourcefile dosh.h:
- * header file for dosh.c. See remarks there.
+/*************************************************************************
*
- * Note: Version numbering in this file relates to XWorkplace version
- * numbering.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- *@@include #define INCL_DOSPROCESS
- *@@include #define INCL_DOSDEVIOCTL // for doshQueryDiskParams only
- *@@include #include <os2.h>
- *@@include #include "helpers\dosh.h"
- */
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:$
+ * $Revision:$
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
-/* This file Copyright (C) 1997-2001 Ulrich Mller,
+/* This file Copyright (C) 1997-2006 Ulrich M�ller,
* Dmitry A. Steklenev.
* This file is part of the "XWorkplace helpers" source package.
- * This is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation, in version 2 as it comes in the
- * "COPYING" file of the XWorkplace main distribution.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ *
+ * 2009-06-15 published under LGPL3 with Ulrich M�ller permission.
+ *
*/
#if __cplusplus
@@ -32,886 +43,10 @@ extern "C" {
#ifndef DOSH_HEADER_INCLUDED
#define DOSH_HEADER_INCLUDED
- /* ******************************************************************
- *
- * Wrappers
- *
- ********************************************************************/
-
- // if DOSH_STANDARDWRAPPERS is #define'd before including dosh.h,
- // all the following Dos* API calls are redirected to the dosh*
- // counterparts
-
- #ifdef DOSH_STANDARDWRAPPERS
-
- #ifdef INCL_DOSPROCESS
-
- APIRET XWPENTRY doshSleep(ULONG msec);
- #define DosSleep(a) doshSleep((a))
-
- #endif
-
- #ifdef INCL_DOSSEMAPHORES
-
- APIRET XWPENTRY doshCreateMutexSem(PSZ pszName,
- PHMTX phmtx,
- ULONG flAttr,
- BOOL32 fState);
- #define DosCreateMutexSem(a, b, c, d) doshCreateMutexSem((a), (b), (c), (d))
-
- APIRET XWPENTRY doshRequestMutexSem(HMTX hmtx, ULONG ulTimeout);
- #define DosRequestMutexSem(h, t) doshRequestMutexSem((h), (t))
-
- APIRET XWPENTRY doshReleaseMutexSem(HMTX hmtx);
- #define DosReleaseMutexSem(h) doshReleaseMutexSem((h))
-
- #endif
-
- #ifdef INCL_DOSEXCEPTIONS
-
- APIRET XWPENTRY doshSetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec);
- #define DosSetExceptionHandler(a) doshSetExceptionHandler((a))
-
- APIRET XWPENTRY doshUnsetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD pERegRec);
- #define DosUnsetExceptionHandler(a) doshUnsetExceptionHandler((a))
-
- #endif
-
- #endif
-
- /* ******************************************************************
- *
- * Miscellaneous
- *
- ********************************************************************/
-
- CHAR doshGetChar(VOID);
-
- BOOL doshQueryShiftState(VOID);
-
- ULONG doshIsWarp4(VOID);
-
- PSZ doshQuerySysErrorMsg(APIRET arc);
-
- ULONG doshQuerySysUptime(VOID);
-
- /* ******************************************************************
- *
- * Memory helpers
- *
- ********************************************************************/
-
- PVOID doshMalloc(ULONG cb,
- APIRET *parc);
-
- APIRET doshAllocArray(ULONG c,
- ULONG cbArrayItem,
- PBYTE *ppv,
- PULONG pcbAllocated);
-
- PVOID doshAllocSharedMem(ULONG ulSize,
- const char* pcszName);
-
- PVOID doshRequestSharedMem(PCSZ pcszName);
-
- /* ******************************************************************
- *
- * Drive helpers
- *
- ********************************************************************/
-
- APIRET doshIsFixedDisk(ULONG ulLogicalDrive,
- PBOOL pfFixed);
-
- #ifdef INCL_DOSDEVIOCTL
-
- // #pragma pack(1)
-
- /*
- * DRIVEPARAMS:
- * structure used for doshQueryDiskParams.
- * removed this, we can directly use BIOSPARAMETERBLOCK
- * V0.9.13 (2001-06-14) [umoeller]
- */
-
- /* typedef struct _DRIVEPARAMS
- {
- BIOSPARAMETERBLOCK bpb;
- // BIOS parameter block. This is the first sector
- // (at byte 0) in each partition. This is defined
- // in the OS2 headers as follows:
-
- typedef struct _BIOSPARAMETERBLOCK {
- 0 USHORT usBytesPerSector;
- // Number of bytes per sector.
- 2 BYTE bSectorsPerCluster;
- // Number of sectors per cluster.
- 3 USHORT usReservedSectors;
- // Number of reserved sectors.
- 5 BYTE cFATs;
- // Number of FATs.
- 6 USHORT cRootEntries;
- // Number of root directory entries.
- 8 USHORT cSectors;
- // Number of sectors.
- 10 BYTE bMedia;
- // Media descriptor.
- 11 USHORT usSectorsPerFAT;
- // Number of secctors per FAT.
- 13 USHORT usSectorsPerTrack;
- // Number of sectors per track.
- 15 USHORT cHeads;
- // Number of heads.
- 17 ULONG cHiddenSectors;
- // Number of hidden sectors.
- 21 ULONG cLargeSectors;
- // Number of large sectors.
- 25 BYTE abReserved[6];
- // Reserved.
- 31 USHORT cCylinders;
- // Number of cylinders defined for the physical
- // device.
- 33 BYTE bDeviceType;
- // Physical layout of the specified device.
- 34 USHORT fsDeviceAttr;
- // A bit field that returns flag information
- // about the specified drive.
- } BIOSPARAMETERBLOCK;
-
- // removed the following fields... these are already
- // in the extended BPB structure, as defined in the
- // Toolkit's BIOSPARAMETERBLOCK struct. Checked this,
- // the definition is the same for the Toolkit 3 and 4.5.
-
- USHORT usCylinders;
- // no. of cylinders
- UCHAR ucDeviceType;
- // device type; according to the IBM Control
- // Program Reference (see DSK_GETDEVICEPARAMS),
- // this value can be:
- // -- 0: 48 TPI low-density diskette drive
- // -- 1: 96 TPI high-density diskette drive
- // -- 2: 3.5-inch 720KB diskette drive
- // -- 3: 8-Inch single-density diskette drive
- // -- 4: 8-Inch double-density diskette drive
- // -- 5: Fixed disk
- // -- 6: Tape drive
- // -- 7: Other (includes 1.44MB 3.5-inch diskette drive
- // and CD-ROMs)
- // -- 8: R/W optical disk
- // -- 9: 3.5-inch 4.0MB diskette drive (2.88MB formatted)
- USHORT usDeviceAttrs;
- // DEVATTR_* flags
- } DRIVEPARAMS, *PDRIVEPARAMS;
- #pragma pack() */
-
- APIRET doshQueryDiskParams(ULONG ulLogicalDrive,
- PBIOSPARAMETERBLOCK pdp);
-
- BYTE doshQueryDriveType(ULONG ulLogicalDrive,
- PBIOSPARAMETERBLOCK pdp,
- BOOL fFixed);
-
- APIRET XWPENTRY doshHasAudioCD(ULONG ulLogicalDrive,
- HFILE hfDrive,
- BOOL fMixedModeCD,
- PBOOL pfAudio);
-
- #endif
-
- VOID XWPENTRY doshEnumDrives(PSZ pszBuffer,
- PCSZ pcszFileSystem,
- BOOL fSkipRemoveables);
- typedef VOID XWPENTRY DOSHENUMDRIVES(PSZ pszBuffer,
- PCSZ pcszFileSystem,
- BOOL fSkipRemoveables);
- typedef DOSHENUMDRIVES *PDOSHENUMDRIVES;
-
CHAR doshQueryBootDrive(VOID);
- #define ERROR_AUDIO_CD_ROM 10000
-
- #define DRVFL_MIXEDMODECD 0x0001
- #define DRVFL_TOUCHFLOPPIES 0x0002
- #define DRVFL_CHECKEAS 0x0004
- #define DRVFL_CHECKLONGNAMES 0x0008
-
- APIRET doshAssertDrive(ULONG ulLogicalDrive,
- ULONG fl);
-
- #ifdef INCL_DOSDEVIOCTL
-
- /*
- *@@ XDISKINFO:
- *
- *@@added V0.9.16 (2002-01-13) [umoeller]
- */
-
- typedef struct _XDISKINFO
- {
- CHAR cDriveLetter; // drive letter
- CHAR cLogicalDrive; // logical drive no.
-
- BOOL fPresent; // if FALSE, drive does not exist
-
- // the following are only valid if fPresent == TRUE
-
- BIOSPARAMETERBLOCK bpb;
- // 0x00 USHORT usBytesPerSector;
- // 0x02 BYTE bSectorsPerCluster;
- // 0x03 USHORT usReservedSectors;
- // 0x05 BYTE cFATs;
- // 0x06 USHORT cRootEntries;
- // 0x08 USHORT cSectors;
- // 0x0a BYTE bMedia;
- // 0x0b USHORT usSectorsPerFAT;
- // 0x0d USHORT usSectorsPerTrack;
- // 0x0f USHORT cHeads;
- // 0x11 ULONG cHiddenSectors;
- // 0x15 ULONG cLargeSectors;
- // 0x19 BYTE abReserved[6];
- // 0x1a USHORT cCylinders;
- // 0x1c BYTE bDeviceType;
- #ifndef DEVTYPE_48TPI
- #define DEVTYPE_48TPI 0x0000
- #define DEVTYPE_96TPI 0x0001
- #define DEVTYPE_35 0x0002
- #define DEVTYPE_8SD 0x0003
- #define DEVTYPE_8DD 0x0004
- #define DEVTYPE_FIXED 0x0005
- #define DEVTYPE_TAPE 0x0006
- #endif
- #define DEVTYPE_OTHER 0x0007
- // includes 1.44 3.5" floppy
- #define DEVTYPE_RWOPTICAL 0x0008
- #define DEVTYPE_35_288MB 0x0009
- // 0x1d USHORT fsDeviceAttr;
- #define DEVATTR_REMOVEABLE 0x0001
- // drive is removeable
- #define DEVATTR_CHANGELINE 0x0002
- // device can determine whether media has
- // been removed since last I/O operation
- #define DEVATTR_GREATER16MB 0x0004
- // physical device driver supports physical
- // addresses > 16 MB
- #define DEVATTR_PARTITIONALREMOVEABLE 0x0008
- // undocumented flag; set for ZIP drives
-
- BYTE bType;
- // do not change these codes, XWorkplace relies
- // on them too to parse WPDisk data
- #define DRVTYPE_HARDDISK 0
- #define DRVTYPE_FLOPPY 1
- #define DRVTYPE_TAPE 2
- #define DRVTYPE_VDISK 3
- #define DRVTYPE_CDROM 4
- #define DRVTYPE_LAN 5
- #define DRVTYPE_PARTITIONABLEREMOVEABLE 6
- #define DRVTYPE_UNKNOWN 255
-
- ULONG flDevice;
- // any combination of the following:
- #define DFL_REMOTE 0x0001
- // drive is remote (not local)
- #define DFL_FIXED 0x0002
- // drive is fixed; otherwise it is removeable!
- // always set for harddisks and zip drives
- #define DFL_PARTITIONABLEREMOVEABLE 0x0004
- // set for zip drives;
- // in that case, DFL_FIXED is set also
- #define DFL_BOOTDRIVE 0x0008
- // drive was booted from
-
- // media flags:
-
- #define DFL_MEDIA_PRESENT 0x1000
- // media is present in drive;
- // -- always set for harddisks,
- // unless the file system is not
- // understood
- // -- always set for remove drives
- // -- always set for A: and B:
- // -- set for CD-ROMS only if data
- // CD-ROM is inserted
- #define DFL_AUDIO_CD 0x2000
- // set for CD-ROMs only, if an audio CD
- // is currently inserted; in that case,
- // DFL_MEDIA_PRESENT is _not_ set
- #define DFL_SUPPORTS_EAS 0x4000
- // drive supports extended attributes
- // (assumption based on DosFSCtl,
- // might not be correct for remote drives;
- // reports correctly for FAT32 though)
- #define DFL_SUPPORTS_LONGNAMES 0x8000
- // drive supports long names; this does not
- // necessarily mean that we support all IFS
- // characters also
-
- // the following are only valid if DFL_MEDIA_PRESENT is set;
- // they are always set for drives A: and B:
-
- CHAR szFileSystem[30];
- // e.g. "FAT" or "HPFS" or "JFS" or "CDFS"
-
- LONG lFileSystem;
- // do not change these codes, XWorkplace relies
- // on them too to parse WPDisk data
- #define FSYS_UNKNOWN 0
- // drive not formatted, or unknown file system
- #define FSYS_FAT 1
- #define FSYS_HPFS_JFS 2
- #define FSYS_CDFS 3
- #define FSYS_CDWFS 6 // not used by WPS!
- // added V0.9.19 (2002-04-25) [umoeller]
- #define FSYS_TVFS 7 // not used by WPS!
- #define FSYS_FAT32_EXT2 8 // not used by WPS!
- #define FSYS_RAMFS 9 // not used by WPS!
- #define FSYS_REMOTE 10
- // NOTE: if this has a negative value, this is
- // the APIRET code from DosQueryFSAttach
-
- // error codes for various operations
- APIRET arcIsFixedDisk,
- arcQueryDiskParams,
- arcQueryMedia,
- arcOpenLongnames;
-
- } XDISKINFO, *PXDISKINFO;
-
- APIRET doshGetDriveInfo(ULONG ulLogicalDrive,
- ULONG fl,
- PXDISKINFO pdi);
-
- #endif
-
- APIRET doshSetLogicalMap(ULONG ulLogicalDrive);
-
- APIRET XWPENTRY doshQueryDiskSize(ULONG ulLogicalDrive, double *pdSize);
- typedef APIRET XWPENTRY DOSHQUERYDISKSIZE(ULONG ulLogicalDrive, double *pdSize);
- typedef DOSHQUERYDISKSIZE *PDOSHQUERYDISKSIZE;
-
- APIRET XWPENTRY doshQueryDiskFree(ULONG ulLogicalDrive, double *pdFree);
- typedef APIRET XWPENTRY DOSHQUERYDISKFREE(ULONG ulLogicalDrive, double *pdFree);
- typedef DOSHQUERYDISKFREE *PDOSHQUERYDISKFREE;
-
- APIRET XWPENTRY doshQueryDiskFSType(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
- typedef APIRET XWPENTRY DOSHQUERYDISKFSTYPE(ULONG ulLogicalDrive, PSZ pszBuf, ULONG cbBuf);
- typedef DOSHQUERYDISKFSTYPE *PDOSHQUERYDISKFSTYPE;
-
- APIRET doshQueryDiskLabel(ULONG ulLogicalDrive,
- PSZ pszVolumeLabel);
-
- APIRET doshSetDiskLabel(ULONG ulLogicalDrive,
- PSZ pszNewLabel);
-
- /* ******************************************************************
- *
- * Module handling helpers
- *
- ********************************************************************/
-
- APIRET doshQueryProcAddr(PCSZ pcszModuleName,
- ULONG ulOrdinal,
- PFN *ppfn);
-
- /*
- *@@ RESOLVEFUNCTION:
- * one of these structures each define
- * a single function import to doshResolveImports.
- *
- *@@added V0.9.3 (2000-04-25) [umoeller]
- */
-
- typedef struct _RESOLVEFUNCTION
- {
- const char *pcszFunctionName;
- PFN *ppFuncAddress;
- } RESOLVEFUNCTION, *PRESOLVEFUNCTION;
-
- typedef const struct _RESOLVEFUNCTION *PCRESOLVEFUNCTION;
-
- APIRET doshResolveImports(PCSZ pcszModuleName,
- HMODULE *phmod,
- PCRESOLVEFUNCTION paResolves,
- ULONG cResolves);
-
- /* ******************************************************************
- *
- * Performance Counters (CPU Load)
- *
- ********************************************************************/
-
- #define CMD_PERF_INFO 0x41
- #define CMD_KI_ENABLE 0x60
- #define CMD_KI_DISABLE 0x61
- #ifndef CMD_KI_RDCNT
- #define CMD_KI_RDCNT 0x63
- typedef APIRET APIENTRY FNDOSPERFSYSCALL(ULONG ulCommand,
- ULONG ulParm1,
- ULONG ulParm2,
- ULONG ulParm3);
- typedef FNDOSPERFSYSCALL *PFNDOSPERFSYSCALL;
- #endif
-
- typedef struct _CPUUTIL
- {
- ULONG ulTimeLow; // low 32 bits of time stamp
- ULONG ulTimeHigh; // high 32 bits of time stamp
- ULONG ulIdleLow; // low 32 bits of idle time
- ULONG ulIdleHigh; // high 32 bits of idle time
- ULONG ulBusyLow; // low 32 bits of busy time
- ULONG ulBusyHigh; // high 32 bits of busy time
- ULONG ulIntrLow; // low 32 bits of interrupt time
- ULONG ulIntrHigh; // high 32 bits of interrupt time
- } CPUUTIL, *PCPUUTIL;
-
- // macro to convert 8-byte (low, high) time value to double
- #define LL2F(high, low) (4294967296.0*(high)+(low))
-
- /*
- *@@ DOSHPERFSYS:
- * structure used with doshPerfOpen.
- *
- *@@added V0.9.7 (2000-12-02) [umoeller]
- *@@changed V0.9.9 (2001-03-14) [umoeller]: added interrupt load
- */
-
- typedef struct _DOSHPERFSYS
- {
- // output: no. of processors on the system
- ULONG cProcessors;
- // output: one CPU load for each CPU
- PLONG palLoads;
-
- // output: one CPU interrupt load for each CPU
- PLONG palIntrs;
-
- // each of the following ptrs points to an array of cProcessors items
- PCPUUTIL paCPUUtils; // CPUUTIL structures
- double *padBusyPrev; // previous "busy" calculations
- double *padTimePrev; // previous "time" calculations
- double *padIntrPrev; // previous "intr" calculations
-
- // private stuff
- HMODULE hmod;
- BOOL fInitialized;
- PFNDOSPERFSYSCALL pDosPerfSysCall;
- } DOSHPERFSYS, *PDOSHPERFSYS;
-
- APIRET doshPerfOpen(PDOSHPERFSYS *ppPerfSys);
-
- APIRET doshPerfGet(PDOSHPERFSYS pPerfSys);
-
- APIRET doshPerfClose(PDOSHPERFSYS *ppPerfSys);
-
- /* ******************************************************************
- *
- * File name parsing
- *
- ********************************************************************/
-
- APIRET doshGetDriveSpec(PCSZ pcszFullFile,
- PSZ pszDrive,
- PULONG pulDriveLen,
- PBOOL pfIsUNC);
-
- PSZ doshGetExtension(PCSZ pcszFilename);
-
- /* ******************************************************************
- *
- * File helpers
- *
- ********************************************************************/
-
- BOOL doshIsFileOnFAT(const char* pcszFileName);
-
- APIRET doshIsValidFileName(const char* pcszFile,
- BOOL fFullyQualified);
-
- BOOL doshMakeRealName(PSZ pszTarget, PSZ pszSource, CHAR cReplace, BOOL fIsFAT);
-
- APIRET doshQueryFileSize(HFILE hFile,
- PULONG pulSize);
-
- APIRET doshQueryPathSize(PCSZ pcszFile,
- PULONG pulSize);
-
- APIRET doshQueryPathAttr(const char* pcszFile,
- PULONG pulAttr);
-
- APIRET doshSetPathAttr(const char* pcszFile,
- ULONG ulAttr);
-
- /* ******************************************************************
- *
- * XFILEs
- *
- ********************************************************************/
-
- /*
- *@@ XFILE:
- *
- *@@added V0.9.16 (2001-10-19) [umoeller]
- */
-
- typedef struct _XFILE
- {
- HFILE hf;
-
- PSZ pszFilename; // as given to doshOpen
- ULONG flOpenMode; // as given to doshOpen
-
- ULONG cbInitial, // intial file size on open (can be 0 if new)
- cbCurrent; // current file size (raised with each write)
-
- PBYTE pbCache; // if != NULL, cached data from doshReadAt
- ULONG cbCache, // size of data in cbCache
- ulReadFrom; // file offset where pbCache was read from
- } XFILE, *PXFILE;
-
- #define XOPEN_READ_EXISTING 0x0001
- #define XOPEN_READWRITE_EXISTING 0x0002
- #define XOPEN_READWRITE_APPEND 0x0003
- #define XOPEN_READWRITE_NEW 0x0004
- #define XOPEN_ACCESS_MASK 0xffff
-
- #define XOPEN_BINARY 0x10000000
-
- APIRET doshOpen(PCSZ pcszFilename,
- ULONG flOpenMode,
- PULONG pcbFile,
- PXFILE *ppFile);
-
- #define DRFL_NOCACHE 0x0001
- #define DRFL_FAILIFLESS 0x0002
-
- APIRET doshReadAt(PXFILE pFile,
- ULONG ulOffset,
- PULONG pcb,
- PBYTE pbData,
- ULONG fl);
-
- APIRET doshWrite(PXFILE pFile,
- ULONG cb,
- PCSZ pbData);
-
- APIRET doshWriteAt(PXFILE pFile,
- ULONG ulOffset,
- ULONG cb,
- PCSZ pbData);
-
- APIRET doshWriteLogEntry(PXFILE pFile,
- const char* pcszFormat,
- ...);
-
- APIRET doshClose(PXFILE *ppFile);
-
- APIRET doshReadText(PXFILE pFile,
- PSZ* ppszContent,
- PULONG pcbRead);
-
- APIRET doshLoadTextFile(PCSZ pcszFile,
- PSZ* ppszContent,
- PULONG pcbRead);
-
- PSZ doshCreateBackupFileName(const char* pszExisting);
-
- APIRET doshCreateTempFileName(PSZ pszTempFileName,
- PCSZ pcszDir,
- PCSZ pcszPrefix,
- PCSZ pcszExt);
-
- APIRET doshWriteTextFile(const char* pszFile,
- const char* pszContent,
- PULONG pulWritten,
- PSZ pszBackup);
-
-
- /* ******************************************************************
- *
- * Directory helpers
- *
- ********************************************************************/
-
- BOOL doshQueryDirExist(PCSZ pcszDir);
-
- APIRET doshCreatePath(PCSZ pcszPath,
- BOOL fHidden);
-
- APIRET doshQueryCurrentDir(PSZ pszBuf);
-
- APIRET doshSetCurrentDir(PCSZ pcszDir);
-
- #define DOSHDELDIR_RECURSE 0x0001
- #define DOSHDELDIR_DELETEFILES 0x0002
-
- APIRET doshDeleteDir(PCSZ pcszDir,
- ULONG flFlags,
- PULONG pulDirs,
- PULONG pulFiles);
-
- APIRET doshCanonicalize(PCSZ pcszFileIn,
- PSZ pszFileOut,
- ULONG cbFileOut);
-
- /* ******************************************************************
- *
- * Process helpers
- *
- ********************************************************************/
-
- ULONG XWPENTRY doshMyPID(VOID);
- typedef ULONG XWPENTRY DOSHMYPID(VOID);
- typedef DOSHMYPID *PDOSHMYPID;
-
- ULONG XWPENTRY doshMyTID(VOID);
- typedef ULONG XWPENTRY DOSHMYTID(VOID);
- typedef DOSHMYTID *PDOSHMYTID;
-
- APIRET doshExecVIO(PCSZ pcszExecWithArgs,
- PLONG plExitCode);
-
- APIRET doshQuickStartSession(PCSZ pcszPath,
- PCSZ pcszParams,
- BOOL fForeground,
- USHORT usPgmCtl,
- BOOL fWait,
- PULONG pulSID,
- PPID ppid,
- PUSHORT pusReturn);
-
- APIRET doshSearchPath(PCSZ pcszPath,
- PCSZ pcszFile,
- PSZ pszExecutable,
- ULONG cbExecutable);
-
- APIRET doshFindExecutable(PCSZ pcszCommand,
- PSZ pszExecutable,
- ULONG cbExecutable,
- PCSZ *papcszExtensions,
- ULONG cExtensions);
-
- /********************************************************************
- *
- * Partition functions
- *
- ********************************************************************/
-
- /*
- *@@ LVMINFO:
- * informational structure created by
- * doshQueryLVMInfo.
- *
- *@@added V0.9.9 (2001-04-07) [umoeller]
- */
-
- typedef struct _LVMINFO
- {
- HMODULE hmodLVM;
-
- } LVMINFO, *PLVMINFO;
-
- /* #define DOSH_PARTITIONS_LIMIT 10
-
- #define PAR_UNUSED 0x00 // Unused
- #define PAR_FAT12SMALL 0x01 // DOS FAT 12-bit < 10 Mb
- #define PAR_XENIXROOT 0x02 // XENIX root
- #define PAR_XENIXUSER 0x03 // XENIX user
- #define PAR_FAT16SMALL 0x04 // DOS FAT 16-bit < 32 Mb
- #define PAR_EXTENDED 0x05 // Extended partition
- #define PAR_FAT16BIG 0x06 // DOS FAT 16-bit > 32 Mb
- #define PAR_HPFS 0x07 // OS/2 HPFS
- #define PAR_AIXBOOT 0x08 // AIX bootable partition
- #define PAR_AIXDATA 0x09 // AIX bootable partition
- #define PAR_BOOTMANAGER 0x0A // OS/2 Boot Manager
- #define PAR_WINDOWS95 0x0B // Windows 95 32-bit FAT
- #define PAR_WINDOWS95LB 0x0C // Windows 95 32-bit FAT with LBA
- #define PAR_VFAT16BIG 0x0E // LBA VFAT (same as 06h but using LBA-mode)
- #define PAR_VFAT16EXT 0x0F // LBA VFAT (same as 05h but using LBA-mode)
- #define PAR_OPUS 0x10 // OPUS
- #define PAR_HID12SMALL 0x11 // OS/2 hidden DOS FAT 12-bit
- #define PAR_COMPAQDIAG 0x12 // Compaq diagnostic
- #define PAR_HID16SMALL 0x14 // OS/2 hidden DOS FAT 16-bit
- #define PAR_HID16BIG 0x16 // OS/2 hidden DOS FAT 16-bit
- #define PAR_HIDHPFS 0x17 // OS/2 hidden HPFS
- #define PAR_WINDOWSSWP 0x18 // AST Windows Swap File
- #define PAR_NECDOS 0x24 // NEC MS-DOS 3.x
- #define PAR_THEOS 0x38 // THEOS
- #define PAR_VENIX 0x40 // VENIX
- #define PAR_RISCBOOT 0x41 // Personal RISC boot
- #define PAR_SFS 0x42 // SFS
- #define PAR_ONTRACK 0x50 // Ontrack
- #define PAR_ONTRACKEXT 0x51 // Ontrack extended partition
- #define PAR_CPM 0x52 // CP/M
- #define PAR_UNIXSYSV 0x63 // UNIX SysV/386
- #define PAR_NOVELL_64 0x64 // Novell
- #define PAR_NOVELL_65 0x65 // Novell
- #define PAR_NOVELL_67 0x67 // Novell
- #define PAR_NOVELL_68 0x68 // Novell
- #define PAR_NOVELL_69 0x69 // Novell
- #define PAR_PCIX 0x75 // PCIX
- #define PAR_MINIX 0x80 // MINIX
- #define PAR_LINUX 0x81 // Linux
- #define PAR_LINUXSWAP 0x82 // Linux Swap Partition
- #define PAR_LINUXFILE 0x83 // Linux File System
- #define PAR_FREEBSD 0xA5 // FreeBSD
- #define PAR_BBT 0xFF // BBT
- */
-
- // one-byte alignment
- #pragma pack(1)
-
- /*
- *@@ PAR_INFO:
- * partition table
- */
-
- typedef struct _PAR_INFO
- {
- BYTE bBootFlag; // 0=not active, 80H = active (boot this partition
- BYTE bBeginHead; // partition begins at this head...
- USHORT rBeginSecCyl; // ...and this sector and cylinder (see below)
- BYTE bFileSysCode; // file system type
- BYTE bEndHead; // partition ends at this head...
- USHORT bEndSecCyl; // ...and this sector and cylinder (see below)
- ULONG lBeginAbsSec; // partition begins at this absolute sector #
- ULONG lTotalSects; // total sectors in this partition
- } PAR_INFO, *PPAR_INFO;
-
- /*
- *@@ MBR_INFO:
- * master boot record table.
- * This has the four primary partitions.
- */
-
- typedef struct _MBR_INFO // MBR
- {
- BYTE aBootCode[0x1BE]; // abBootCode master boot executable code
- PAR_INFO sPrtnInfo[4]; // primary partition entries
- USHORT wPrtnTblSig; // partition table signature (aa55H)
- } MBR_INFO, *PMBR_INFO;
-
- /*
- *@@ SYS_INFO:
- *
- */
-
- typedef struct _SYS_INFO
- {
- BYTE startable;
- BYTE unknown[3];
- BYTE bootable;
- BYTE name[8];
- BYTE reservd[3];
- } SYS_INFO, *PSYS_INFO;
-
- /*
- *@@ SYE_INFO:
- *
- */
-
- typedef struct _SYE_INFO
- {
- BYTE bootable;
- BYTE name[8];
- } SYE_INFO, *PSYE_INFO;
-
- /*
- *@@ EXT_INFO:
- *
- */
-
- typedef struct _EXT_INFO
- {
- BYTE aBootCode[0x18A]; // abBootCode master boot executable code
- SYE_INFO sBmNames[4]; // System Names
- BYTE bReserved[16]; // reserved
- PAR_INFO sPrtnInfo[4]; // partitioms entrys
- USHORT wPrtnTblSig; // partition table signature (aa55H)
- } EXT_INFO, *PEXT_INFO;
-
- typedef struct _PARTITIONINFO *PPARTITIONINFO;
-
- /*
- *@@ PARTITIONINFO:
- * informational structure returned
- * by doshGetPartitionsList. One of
- * these items is created for each
- * bootable partition.
- */
-
- typedef struct _PARTITIONINFO
- {
- BYTE bDisk; // drive number
- CHAR cLetter; // probable drive letter or ' ' if none
- BYTE bFSType; // file system type
- PCSZ pcszFSType; // file system name (as returned by
- // doshType2FSName, can be NULL!)
- BOOL fPrimary; // primary partition?
- BOOL fBootable; // bootable by Boot Manager?
- CHAR szBootName[21]; // Boot Manager name, if (fBootable)
- // extended for LVM names V0.9.20 (2002-08-10) [umoeller]
- ULONG ulSize; // size MBytes
- PPARTITIONINFO pNext; // next info or NULL if last
- } PARTITIONINFO;
-
- UINT doshQueryDiskCount(VOID);
-
- APIRET doshReadSector(USHORT disk,
- void *buff,
- USHORT head,
- USHORT cylinder,
- USHORT sector);
-
- // restore original alignment
- #pragma pack()
-
- const char* doshType2FSName(unsigned char bFSType);
-
- APIRET doshGetBootManager(USHORT *pusDisk,
- USHORT *pusPart,
- PAR_INFO *BmInfo);
-
- typedef struct _PARTITIONSLIST
- {
- PLVMINFO pLVMInfo; // != NULL if LVM is installed
-
- // partitions array
- PPARTITIONINFO pPartitionInfo;
- USHORT cPartitions;
- } PARTITIONSLIST, *PPARTITIONSLIST;
-
- APIRET doshGetPartitionsList(PPARTITIONSLIST *ppList,
- PUSHORT pusContext);
-
- APIRET doshFreePartitionsList(PPARTITIONSLIST ppList);
-
- APIRET doshQueryLVMInfo(PLVMINFO *ppLVMInfo);
-
- APIRET doshReadLVMPartitions(PLVMINFO pInfo,
- PPARTITIONINFO *ppPartitionInfo,
- PUSHORT pcPartitions);
-
- VOID doshFreeLVMInfo(PLVMINFO pInfo);
-
- /* ******************************************************************
- *
- * Wildcard matching
- *
- ********************************************************************/
-
- BOOL doshMatchCase(PCSZ pcszMask,
- PCSZ pcszName);
-
- BOOL doshMatchCaseNoPath(const char *pcszMask,
- const char *pcszName);
-
- BOOL doshMatch(PCSZ pcszMask,
- PCSZ pcszName);
-
#endif
#if __cplusplus
}
#endif
-
diff --git a/sal/osl/os2/helpers/except.h b/sal/osl/os2/helpers/except.h
index 6a898ba84c99..b2d6b17ca702 100644
--- a/sal/osl/os2/helpers/except.h
+++ b/sal/osl/os2/helpers/except.h
@@ -1,3 +1,32 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:$
+ * $Revision:$
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
/*
*@@sourcefile except.h:
@@ -15,15 +44,10 @@
*/
/*
- * Copyright (C) 1999-2000 Ulrich Mller.
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, in version 2 as it comes in the COPYING
- * file of the XFolder main distribution.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * Copyright (C) 1999-2000 Ulrich M�ller.
+ *
+ * 2009-06-15 published under LGPL3 with Ulrich M�ller permission.
+ *
*/
#if __cplusplus
diff --git a/sal/osl/os2/helpers/setup.h b/sal/osl/os2/helpers/setup.h
index 015d93019f21..6c02d8b655fb 100644
--- a/sal/osl/os2/helpers/setup.h
+++ b/sal/osl/os2/helpers/setup.h
@@ -1,3 +1,35 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile:$
+ * $Revision:$
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * 2009-06-15 published under LGPL3 with Ulrich M�ller permission.
+ *
+ *
+ ************************************************************************/
/*
* setup.h:
diff --git a/sal/osl/os2/module.c b/sal/osl/os2/module.c
index c8c9731a95ed..901c029429c4 100644
--- a/sal/osl/os2/module.c
+++ b/sal/osl/os2/module.c
@@ -109,7 +109,7 @@ oslModule SAL_CALL osl_loadModule(rtl_uString *ustrModuleName, sal_Int32 nRtldMo
pModule = (oslModule)hModule;
else
{
- sal_Char szError[ 120 ];
+ sal_Char szError[ PATH_MAX*2 ];
sprintf( szError, "Module: %s; rc: %d;\nReason: %s;\n"
"Please contact technical support and report above informations.\n\n",
buffer, rc, szErrorMessage );
diff --git a/sal/osl/os2/process.c b/sal/osl/os2/process.c
index 793be57950b6..a3408ddbf7d0 100644
--- a/sal/osl/os2/process.c
+++ b/sal/osl/os2/process.c
@@ -551,7 +551,8 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName,
{
for (i = first; pszArguments[i] != NULL; i++)
n += strlen(pszArguments[i]) + 1;
- args = (sal_Char*)malloc(n);
+ // YD DosStartSession requires low-mem buffers!
+ args = (sal_Char*)_tmalloc(n);
*args = '\0';
for (i = first; pszArguments[i] != NULL; i++)
{
@@ -567,7 +568,8 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName,
{
for (i = 0; pszEnvironments[i] != NULL; i++)
n += strlen(pszEnvironments[i]) + 1;
- envs = (sal_Char*)malloc(n + 1);
+ // YD DosStartSession requires low-mem buffers!
+ envs = (sal_Char*)_tmalloc(n + 1);
pStr = (sal_Char*)envs;
for (i = 0; pszEnvironments[i] != NULL; i++)
{
@@ -660,9 +662,9 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName,
if(envs)
- free(envs);
+ _tfree(envs);
if(args)
- free(args);
+ _tfree(args);
if( rc != NO_ERROR )
return osl_Process_E_Unknown;
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index bd5b54a6d8c3..c8ebf5ad11c5 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -31,1207 +31,920 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sal.hxx"
-
-/************************************************************************
- * ToDo
- *
- * Fix osl_getCanonicalName
- *
- * - Fix: check for corresponding struct sizes in exported functions
- * - check size/use of oslDirectory
- * - check size/use of oslDirectoryItem
- * - check size/use of oslFileStatus
- * - check size/use of oslVolumeDeviceHandle
- * - check size/use of oslVolumeInfo
- * - check size/use of oslFileHandle
- ***********************************************************************/
-
-#include <algorithm>
-#include <limits>
-#include "system.h"
-#include <rtl/alloc.h>
-
#include "osl/file.hxx"
+#include "osl/diagnose.h"
+#include "rtl/alloc.h"
-#include <sal/types.h>
-#include <osl/thread.h>
-#include <osl/diagnose.h>
+#include "system.h"
#include "file_error_transl.h"
-#include <osl/time.h>
-
-#ifndef _FILE_URL_H_
#include "file_url.h"
-#endif
-
-#include "file_path_helper.hxx"
-#include "uunxapi.hxx"
-
-#include <sys/mman.h>
-
-#ifdef HAVE_STATFS_H
-#undef HAVE_STATFS_H
-#endif
+#include <algorithm>
+#include <limits>
-#ifndef _STRING_H
#include <string.h>
-#endif
-
-#if defined(SOLARIS)
-#include <sys/mnttab.h>
-#include <sys/statvfs.h>
-#define HAVE_STATFS_H
-#include <sys/fs/ufs_quota.h>
-static const sal_Char* MOUNTTAB="/etc/mnttab";
-
-#elif defined(LINUX)
-#include <mntent.h>
-#include <sys/vfs.h>
-#define HAVE_STATFS_H
-#include <sys/quota.h>
-#include <ctype.h>
-static const sal_Char* MOUNTTAB="/etc/mtab";
-
-#elif defined(NETBSD) || defined(FREEBSD)
-#include <sys/param.h>
-#include <sys/ucred.h>
-#include <sys/mount.h>
-#include <ufs/ufs/quota.h>
-#include <ctype.h>
-#define HAVE_STATFS_H
-/* No mounting table on *BSD
- * This information is stored only in the kernel. */
-/* static const sal_Char* MOUNTTAB="/etc/mtab"; */
-
-#elif defined(IRIX)
-#include <mntent.h>
-#include <sys/mount.h>
-#include <sys/statvfs.h>
-#define HAVE_STATFS_H
-#include <sys/quota.h>
-#include <ctype.h>
-static const sal_Char* MOUNTTAB="/etc/mtab";
+#include <sys/mman.h>
-#elif defined(MACOSX)
-#include <ufs/ufs/quota.h>
-#include <ctype.h>
-// static const sal_Char* MOUNTTAB="/etc/mtab";
+#if defined(MACOSX)
#include <sys/param.h>
#include <sys/mount.h>
-#define HAVE_STATFS_H
#define HAVE_O_EXLOCK
// add MACOSX Time Value
-
#define TimeValue CFTimeValue
#include <CoreFoundation/CoreFoundation.h>
#undef TimeValue
-#endif
-
-#ifdef _DIRENT_HAVE_D_TYPE
-#include "file_impl.hxx"
- oslDirectoryItemImpl* oslDirectoryItemImpl_CreateNew( rtl_uString* _ustrFilePath, bool _bHasDType, unsigned char _DType )
- {
- oslDirectoryItemImpl *pItemObject = (oslDirectoryItemImpl*) malloc( sizeof( oslDirectoryItemImpl ) );
- pItemObject->RefCount = 1;
- pItemObject->bHasType = _bHasDType;
- pItemObject->DType = _DType;
- pItemObject->ustrFilePath = _ustrFilePath;
-
- return pItemObject;
- }
-
- void oslDirectoryItemImpl_Destroy( oslDirectoryItemImpl* pItem )
- {
- if( pItem->ustrFilePath ) {
- rtl_uString_release( pItem->ustrFilePath );
- pItem->ustrFilePath = NULL;
- }
- free( pItem );
- }
-
- void oslDirectoryItemImpl_acquire( oslDirectoryItemImpl* pItem )
- {
- pItem->RefCount ++;
- }
-
- void oslDirectoryItemImpl_release( oslDirectoryItemImpl* pItem )
- {
- pItem->RefCount --;
-
- if( pItem->RefCount <= 0 )
- oslDirectoryItemImpl_Destroy( pItem );
- }
-#endif
-
-#if OSL_DEBUG_LEVEL > 1
-
- extern void debug_ustring(rtl_uString*);
-
-#endif
-
+#endif /* MACOSX */
#ifdef DEBUG_OSL_FILE
+# define OSL_FILE_TRACE 0 ? (void)(0) : osl_trace
# define PERROR( a, b ) perror( a ); fprintf( stderr, b )
#else
+# define OSL_FILE_TRACE 1 ? (void)(0) : osl_trace
# define PERROR( a, b )
#endif
-extern "C" oslFileHandle osl_createFileHandleFromFD( int fd );
-
-/******************************************************************************
+/*******************************************************************
*
- * Data Type Definition
+ * FileHandle_Impl interface
*
- ******************************************************************************/
-
-#if 0
-/* FIXME: reintroducing this may save some extra bytes per Item */
-typedef struct
-{
- rtl_uString* ustrFileName; /* holds native file name */
- rtl_uString* ustrDirPath; /* holds native dir path */
- sal_uInt32 RefCount;
-} oslDirectoryItemImpl;
-#endif
-
-typedef struct
-{
- rtl_uString* ustrPath; /* holds native directory path */
- DIR* pDirStruct;
-} oslDirectoryImpl;
-
-
-typedef struct
+ ******************************************************************/
+struct FileHandle_Impl
{
- rtl_uString* ustrFilePath; /* holds native file path */
- int fd;
- sal_Bool bLocked;
-} oslFileHandleImpl;
-
+ rtl_String * m_strFilePath; /* holds native file path */
+ int m_fd;
-typedef struct _oslVolumeDeviceHandleImpl
-{
- sal_Char pszMountPoint[PATH_MAX];
- sal_Char pszFilePath[PATH_MAX];
- sal_Char pszDevice[PATH_MAX];
- sal_Char ident[4];
- sal_uInt32 RefCount;
-} oslVolumeDeviceHandleImpl;
+ /** State
+ */
+ enum StateBits
+ {
+ STATE_SEEKABLE = 1, /* default */
+ STATE_READABLE = 2, /* default */
+ STATE_WRITEABLE = 4, /* open() sets, write() requires, else osl_File_E_BADF */
+ STATE_MODIFIED = 8 /* write() sets, flush() resets */
+ };
+ int m_state;
+ sal_uInt64 m_size; /* file size */
+ off_t m_offset; /* physical offset from begin of file */
+ off_t m_fileptr; /* logical offset from begin of file */
-/******************************************************************************
- *
- * static members
- *
- *****************************************************************************/
+ off_t m_bufptr; /* buffer offset from begin of file */
+ size_t m_buflen; /* buffer filled [0, m_bufsiz - 1] */
-static const char * pFileLockEnvVar = (char *) -1;
+ size_t m_bufsiz;
+ sal_uInt8 * m_buffer;
+ explicit FileHandle_Impl (int fd, char const * path = "<anon>");
+ ~FileHandle_Impl();
-/******************************************************************************
- *
- * C-String Function Declarations
- *
- *****************************************************************************/
+ static void* operator new (size_t n);
+ static void operator delete (void * p, size_t);
-static oslFileError osl_psz_getVolumeInformation(const sal_Char* , oslVolumeInfo* pInfo, sal_uInt32 uFieldMask);
-static oslFileError osl_psz_removeFile(const sal_Char* pszPath);
-static oslFileError osl_psz_createDirectory(const sal_Char* pszPath);
-static oslFileError osl_psz_removeDirectory(const sal_Char* pszPath);
-static oslFileError osl_psz_copyFile(const sal_Char* pszPath, const sal_Char* pszDestPath);
-static oslFileError osl_psz_moveFile(const sal_Char* pszPath, const sal_Char* pszDestPath);
-static oslFileError osl_psz_setFileAttributes(const sal_Char* pszFilePath, sal_uInt64 uAttributes);
-static oslFileError osl_psz_setFileTime(const sal_Char* strFilePath, const TimeValue* pCreationTime, const TimeValue* pLastAccessTime, const TimeValue* pLastWriteTime);
+ static size_t getpagesize();
+ sal_uInt64 getPos() const;
+ oslFileError setPos (sal_uInt64 uPos);
-/******************************************************************************
- *
- * Static Module Utility Function Declarations
- *
- *****************************************************************************/
+ sal_uInt64 getSize() const;
-static oslFileError oslDoCopy(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, mode_t nMode, size_t nSourceSize, int DestFileExists);
-static oslFileError oslChangeFileModes(const sal_Char* pszFileName, mode_t nMode, time_t nAcTime, time_t nModTime, uid_t nUID, gid_t nGID);
-static int oslDoCopyLink(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName);
-static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, size_t nSourceSize, mode_t mode);
-static oslFileError oslDoMoveFile(const sal_Char* pszPath, const sal_Char* pszDestPath);
-static rtl_uString* oslMakeUStrFromPsz(const sal_Char* pszStr,rtl_uString** uStr);
+ oslFileError readAt (
+ off_t nOffset,
+ void * pBuffer,
+ size_t nBytesRequested,
+ sal_uInt64 * pBytesRead);
-/******************************************************************************
- *
- * Non-Static Utility Function Declarations
- *
- *****************************************************************************/
+ oslFileError writeAt (
+ off_t nOffset,
+ void const * pBuffer,
+ size_t nBytesToWrite,
+ sal_uInt64 * pBytesWritten);
-extern "C" int UnicodeToText( char *, size_t, const sal_Unicode *, sal_Int32 );
-extern "C" int TextToUnicode(
- const char* text, size_t text_buffer_size, sal_Unicode* unic_text, sal_Int32 unic_text_buffer_size);
+ oslFileError readFileAt (
+ off_t nOffset,
+ void * pBuffer,
+ size_t nBytesRequested,
+ sal_uInt64 * pBytesRead);
-/******************************************************************************
- *
- * 'removeable device' aka floppy functions
- *
- *****************************************************************************/
+ oslFileError writeFileAt (
+ off_t nOffset,
+ void const * pBuffer,
+ size_t nBytesToWrite,
+ sal_uInt64 * pBytesWritten);
-static oslVolumeDeviceHandle osl_isFloppyDrive(const sal_Char* pszPath);
-static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy);
-static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy);
+ oslFileError readLineAt (
+ off_t nOffset,
+ sal_Sequence ** ppSequence,
+ sal_uInt64 * pBytesRead);
+ oslFileError writeSequence_Impl (
+ sal_Sequence ** ppSequence,
+ size_t * pnOffset,
+ const void * pBuffer,
+ size_t nBytes);
-#if defined(SOLARIS)
-static sal_Bool osl_isFloppyMounted(sal_Char* pszPath, sal_Char* pszMountPath);
-static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, sal_Char* pBuffer);
-static sal_Bool osl_checkFloppyPath(sal_Char* pszPath, sal_Char* pszFilePath, sal_Char* pszDevicePath);
-#endif
+ oslFileError syncFile();
-#if defined(LINUX)
-static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice);
-static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem);
-#endif
+ /** Buffer cache / allocator.
+ */
+ class Allocator
+ {
+ rtl_cache_type * m_cache;
+ size_t m_bufsiz;
+ Allocator (Allocator const &);
+ Allocator & operator= (Allocator const &);
-#if defined(IRIX)
-static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice);
-static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem);
-#endif
+ public:
+ static Allocator & get();
-#ifdef DEBUG_OSL_FILE
-static void osl_printFloppyHandle(oslVolumeDeviceHandleImpl* hFloppy);
-#endif
+ void allocate (sal_uInt8 ** ppBuffer, size_t * pnSize);
+ void deallocate (sal_uInt8 * pBuffer);
-#ifdef MACOSX
+ protected:
+ Allocator();
+ ~Allocator();
+ };
+};
/*******************************************************************
- * adjustLockFlags
+ *
+ * FileHandle_Impl implementation
+ *
******************************************************************/
-/* The AFP implementation of MacOS X 10.4 treats O_EXLOCK in a way
- * that makes it impossible for OOo to create a backup copy of the
- * file it keeps opened. OTOH O_SHLOCK for AFP behaves as desired by
- * the OOo file handling, so we need to check the path of the file
- * for the filesystem name.
- */
-
-static int adjustLockFlags(const char * path, int flags)
+FileHandle_Impl::Allocator &
+FileHandle_Impl::Allocator::get()
{
- struct statfs s;
+ static Allocator g_aBufferAllocator;
+ return g_aBufferAllocator;
+}
- if( 0 <= statfs( path, &s ) )
+FileHandle_Impl::Allocator::Allocator()
+ : m_cache (0),
+ m_bufsiz (0)
+{
+ size_t const pagesize = FileHandle_Impl::getpagesize();
+ if (size_t(-1) != pagesize)
{
- if( 0 == strncmp("afpfs", s.f_fstypename, 5) )
- {
- flags &= ~O_EXLOCK;
- flags |= O_SHLOCK;
- }
- else
- {
- /* Needed flags to allow opening a webdav file */
- flags &= ~( O_EXLOCK | O_SHLOCK );
- }
+ m_cache = rtl_cache_create (
+ "osl_file_buffer_cache", pagesize, 0, 0, 0, 0, 0, 0, 0);
+ if (0 != m_cache)
+ m_bufsiz = pagesize;
}
-
- return flags;
}
-
-#endif
-
-
-/*******************************************************************
- * osl_openDirectory
- ******************************************************************/
-
-oslFileError SAL_CALL osl_openDirectory(rtl_uString* ustrDirectoryURL, oslDirectory* pDirectory)
+FileHandle_Impl::Allocator::~Allocator()
{
- rtl_uString* ustrSystemPath = NULL;
- oslFileError eRet;
-
- char path[PATH_MAX];
-
- OSL_ASSERT(ustrDirectoryURL && (ustrDirectoryURL->length > 0));
- OSL_ASSERT(pDirectory);
-
- if (0 == ustrDirectoryURL->length )
- return osl_File_E_INVAL;
-
- /* convert file URL to system path */
- eRet = osl_getSystemPathFromFileURL_Ex(ustrDirectoryURL, &ustrSystemPath, sal_False);
-
- if( osl_File_E_None != eRet )
- return eRet;
-
- osl_systemPathRemoveSeparator(ustrSystemPath);
+ rtl_cache_destroy (m_cache), m_cache = 0;
+}
- /* convert unicode path to text */
- if ( UnicodeToText( path, PATH_MAX, ustrSystemPath->buffer, ustrSystemPath->length )
-#ifdef MACOSX
- && macxp_resolveAlias( path, PATH_MAX ) == 0
-#endif /* MACOSX */
- )
- {
- /* open directory */
- DIR *pdir = opendir( path );
+void FileHandle_Impl::Allocator::allocate (sal_uInt8 ** ppBuffer, size_t * pnSize)
+{
+ OSL_PRECOND((0 != ppBuffer) && (0 != pnSize), "FileHandle_Impl::Allocator::allocate(): contract violation");
+ *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache)), *pnSize = m_bufsiz;
+}
+void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer)
+{
+ if (0 != pBuffer)
+ rtl_cache_free (m_cache, pBuffer);
+}
- if( pdir )
- {
- /* create and initialize impl structure */
- oslDirectoryImpl* pDirImpl = (oslDirectoryImpl*) rtl_allocateMemory( sizeof(oslDirectoryImpl) );
+FileHandle_Impl::FileHandle_Impl (int fd, char const * path)
+ : m_strFilePath (0),
+ m_fd (fd),
+ m_state (STATE_SEEKABLE | STATE_READABLE),
+ m_size (0),
+ m_offset (0),
+ m_fileptr (0),
+ m_bufptr (-1),
+ m_buflen (0),
+ m_bufsiz (0),
+ m_buffer (0)
+{
+ rtl_string_newFromStr (&m_strFilePath, path);
+ Allocator::get().allocate (&m_buffer, &m_bufsiz);
+ if (0 != m_buffer)
+ memset (m_buffer, 0, m_bufsiz);
+}
+FileHandle_Impl::~FileHandle_Impl()
+{
+ Allocator::get().deallocate (m_buffer), m_buffer = 0;
+ rtl_string_release (m_strFilePath), m_strFilePath = 0;
+}
- if( pDirImpl )
- {
- pDirImpl->pDirStruct = pdir;
- pDirImpl->ustrPath = ustrSystemPath;
+void* FileHandle_Impl::operator new (size_t n)
+{
+ return rtl_allocateMemory(n);
+}
+void FileHandle_Impl::operator delete (void * p, size_t)
+{
+ rtl_freeMemory(p);
+}
- *pDirectory = (oslDirectory) pDirImpl;
- return osl_File_E_None;
- }
- else
- {
- errno = ENOMEM;
- closedir( pdir );
- }
- }
- else
- {
- /* should be removed by optimizer in product version */
- PERROR( "osl_openDirectory", path );
- }
- }
+size_t FileHandle_Impl::getpagesize()
+{
+#if defined(FREEBSD) || defined(NETBSD) || defined(MACOSX)
+ return sal::static_int_cast< size_t >(::getpagesize());
+#else /* POSIX */
+ return sal::static_int_cast< size_t >(::sysconf(_SC_PAGESIZE));
+#endif /* xBSD || POSIX */
+}
- rtl_uString_release( ustrSystemPath );
+sal_uInt64 FileHandle_Impl::getPos() const
+{
+ return sal::static_int_cast< sal_uInt64 >(m_fileptr);
+}
- return oslTranslateFileError(OSL_FET_ERROR, errno);
+oslFileError FileHandle_Impl::setPos (sal_uInt64 uPos)
+{
+ OSL_FILE_TRACE("FileHandle_Impl::setPos(%d, %lld) => %lld", m_fd, getPos(), uPos);
+ m_fileptr = sal::static_int_cast< off_t >(uPos);
+ return osl_File_E_None;
}
-/****************************************************************************/
-/* osl_closeDirectory */
-/****************************************************************************/
+sal_uInt64 FileHandle_Impl::getSize() const
+{
+ off_t const bufend = std::max((off_t)(0), m_bufptr) + m_buflen;
+ return std::max(m_size, sal::static_int_cast< sal_uInt64 >(bufend));
+}
-oslFileError SAL_CALL osl_closeDirectory( oslDirectory Directory )
+oslFileError FileHandle_Impl::readAt (
+ off_t nOffset,
+ void * pBuffer,
+ size_t nBytesRequested,
+ sal_uInt64 * pBytesRead)
{
- oslDirectoryImpl* pDirImpl = (oslDirectoryImpl*) Directory;
- oslFileError err = osl_File_E_None;
+ OSL_PRECOND((m_state & STATE_SEEKABLE), "FileHandle_Impl::readAt(): not seekable");
+ if (!(m_state & STATE_SEEKABLE))
+ return osl_File_E_SPIPE;
- OSL_ASSERT( Directory );
+ OSL_PRECOND((m_state & STATE_READABLE), "FileHandle_Impl::readAt(): not readable");
+ if (!(m_state & STATE_READABLE))
+ return osl_File_E_BADF;
- if( NULL == pDirImpl )
- return osl_File_E_INVAL;
+#if defined(LINUX) || defined(SOLARIS)
- /* close directory */
- if( closedir( pDirImpl->pDirStruct ) )
+ ssize_t nBytes = ::pread (m_fd, pBuffer, nBytesRequested, nOffset);
+ if ((-1 == nBytes) && (EOVERFLOW == errno))
{
- err = oslTranslateFileError(OSL_FET_ERROR, errno);
+ /* Some 'pread()'s fail with EOVERFLOW when reading at (or past)
+ * end-of-file, different from 'lseek() + read()' behaviour.
+ * Returning '0 bytes read' and 'osl_File_E_None' instead.
+ */
+ nBytes = 0;
}
+ if (-1 == nBytes)
+ return oslTranslateFileError (OSL_FET_ERROR, errno);
- /* cleanup members */
- rtl_uString_release( pDirImpl->ustrPath );
-
- rtl_freeMemory( pDirImpl );
-
- return err;
-}
-
-/**********************************************
- * osl_readdir_impl_
- *
- * readdir wrapper, filters out "." and ".."
- * on request
- *********************************************/
-
-static struct dirent* osl_readdir_impl_(DIR* pdir, sal_Bool bFilterLocalAndParentDir)
-{
- struct dirent* pdirent;
+#else /* !(LINUX || SOLARIS) */
- while ((pdirent = readdir(pdir)) != NULL)
+ if (nOffset != m_offset)
{
- if (bFilterLocalAndParentDir &&
- ((0 == strcmp(pdirent->d_name, ".")) || (0 == strcmp(pdirent->d_name, ".."))))
- continue;
- else
- break;
+ if (-1 == ::lseek (m_fd, nOffset, SEEK_SET))
+ return oslTranslateFileError (OSL_FET_ERROR, errno);
+ m_offset = nOffset;
}
- return pdirent;
-}
-
-/****************************************************************************
- * osl_getNextDirectoryItem
- ***************************************************************************/
-
-oslFileError SAL_CALL osl_getNextDirectoryItem(oslDirectory Directory, oslDirectoryItem* pItem, sal_uInt32 /*uHint*/)
-{
- oslDirectoryImpl* pDirImpl = (oslDirectoryImpl*)Directory;
- rtl_uString* ustrFileName = NULL;
- rtl_uString* ustrFilePath = NULL;
- struct dirent* pEntry;
+ ssize_t nBytes = ::read (m_fd, pBuffer, nBytesRequested);
+ if (-1 == nBytes)
+ return oslTranslateFileError (OSL_FET_ERROR, errno);
+ m_offset += nBytes;
- OSL_ASSERT(Directory);
- OSL_ASSERT(pItem);
+#endif /* !(LINUX || SOLARIS) */
- if ((NULL == Directory) || (NULL == pItem))
- return osl_File_E_INVAL;
+ OSL_FILE_TRACE("FileHandle_Impl::readAt(%d, %lld, %ld)", m_fd, nOffset, nBytes);
+ *pBytesRead = nBytes;
+ return osl_File_E_None;
+}
- pEntry = osl_readdir_impl_(pDirImpl->pDirStruct, sal_True);
+oslFileError FileHandle_Impl::writeAt (
+ off_t nOffset,
+ void const * pBuffer,
+ size_t nBytesToWrite,
+ sal_uInt64 * pBytesWritten)
+{
+ OSL_PRECOND((m_state & STATE_SEEKABLE), "FileHandle_Impl::writeAt(): not seekable");
+ if (!(m_state & STATE_SEEKABLE))
+ return osl_File_E_SPIPE;
- if (NULL == pEntry)
- return osl_File_E_NOENT;
+ OSL_PRECOND((m_state & STATE_WRITEABLE), "FileHandle_Impl::writeAt(): not writeable");
+ if (!(m_state & STATE_WRITEABLE))
+ return osl_File_E_BADF;
+#if defined(LINUX) || defined(SOLARIS)
-#if defined(MACOSX)
+ ssize_t nBytes = ::pwrite (m_fd, pBuffer, nBytesToWrite, nOffset);
+ if (-1 == nBytes)
+ return oslTranslateFileError (OSL_FET_ERROR, errno);
- // convert decomposed filename to precomposed unicode
- char composed_name[BUFSIZ];
- CFMutableStringRef strRef = CFStringCreateMutable (NULL, 0 );
- CFStringAppendCString( strRef, pEntry->d_name, kCFStringEncodingUTF8 ); //UTF8 is default on Mac OSX
- CFStringNormalize( strRef, kCFStringNormalizationFormC );
- CFStringGetCString( strRef, composed_name, BUFSIZ, kCFStringEncodingUTF8 );
- CFRelease( strRef );
- rtl_string2UString( &ustrFileName, composed_name, strlen( composed_name),
- osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
-
-#else // not MACOSX
- /* convert file name to unicode */
- rtl_string2UString( &ustrFileName, pEntry->d_name, strlen( pEntry->d_name ),
- osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
- OSL_ASSERT(ustrFileName != 0);
+#else /* !(LINUX || SOLARIS) */
-#endif
+ if (nOffset != m_offset)
+ {
+ if (-1 == ::lseek (m_fd, nOffset, SEEK_SET))
+ return oslTranslateFileError (OSL_FET_ERROR, errno);
+ m_offset = nOffset;
+ }
- osl_systemPathMakeAbsolutePath(pDirImpl->ustrPath, ustrFileName, &ustrFilePath);
- rtl_uString_release( ustrFileName );
+ ssize_t nBytes = ::write (m_fd, pBuffer, nBytesToWrite);
+ if (-1 == nBytes)
+ return oslTranslateFileError (OSL_FET_ERROR, errno);
+ m_offset += nBytes;
-#ifdef _DIRENT_HAVE_D_TYPE
- if(*pItem)
- oslDirectoryItemImpl_release( ( oslDirectoryItemImpl* )( *pItem ) );
+#endif /* !(LINUX || SOLARIS) */
- *pItem = (oslDirectoryItem) oslDirectoryItemImpl_CreateNew( ustrFilePath, true, pEntry->d_type );
-#else
- /* use path as directory item */
- *pItem = (oslDirectoryItem) ustrFilePath;
-#endif
+ OSL_FILE_TRACE("FileHandle_Impl::writeAt(%d, %lld, %ld)", m_fd, nOffset, nBytes);
+ m_size = std::max (m_size, sal::static_int_cast< sal_uInt64 >(nOffset + nBytes));
+ *pBytesWritten = nBytes;
return osl_File_E_None;
}
-/****************************************************************************/
-/* osl_getDirectoryItem */
-/****************************************************************************/
-
-oslFileError SAL_CALL osl_getDirectoryItem( rtl_uString* ustrFileURL, oslDirectoryItem* pItem )
+oslFileError FileHandle_Impl::readFileAt (
+ off_t nOffset,
+ void * pBuffer,
+ size_t nBytesRequested,
+ sal_uInt64 * pBytesRead)
{
- rtl_uString* ustrSystemPath = NULL;
- oslFileError osl_error = osl_File_E_INVAL;
-
- OSL_ASSERT(ustrFileURL);
- OSL_ASSERT(pItem);
-
- if (0 == ustrFileURL->length || NULL == pItem)
- return osl_File_E_INVAL;
-
- osl_error = osl_getSystemPathFromFileURL_Ex(ustrFileURL, &ustrSystemPath, sal_False);
-
- if (osl_File_E_None != osl_error)
- return osl_error;
-
- osl_systemPathRemoveSeparator(ustrSystemPath);
-
- if (0 == access_u(ustrSystemPath, F_OK))
+ if (0 == (m_state & STATE_SEEKABLE))
{
-#ifdef _DIRENT_HAVE_D_TYPE
- *pItem = (oslDirectoryItem) oslDirectoryItemImpl_CreateNew( ustrSystemPath, false );
-#else
- *pItem = (oslDirectoryItem)ustrSystemPath;
-#endif
- osl_error = osl_File_E_None;
+ // not seekable (pipe)
+ ssize_t nBytes = ::read (m_fd, pBuffer, nBytesRequested);
+ if (-1 == nBytes)
+ return oslTranslateFileError (OSL_FET_ERROR, errno);
+ *pBytesRead = nBytes;
+ return osl_File_E_None;
}
- else
+ else if (0 == m_buffer)
{
- osl_error = oslTranslateFileError(OSL_FET_ERROR, errno);
- rtl_uString_release(ustrSystemPath);
+ // not buffered
+ return readAt (nOffset, pBuffer, nBytesRequested, pBytesRead);
}
- return osl_error;
-}
+ else
+ {
+ sal_uInt8 * buffer = static_cast<sal_uInt8*>(pBuffer);
+ for (*pBytesRead = 0; nBytesRequested > 0; )
+ {
+ off_t const bufptr = (nOffset / m_bufsiz) * m_bufsiz;
+ size_t const bufpos = (nOffset % m_bufsiz);
+ if (bufptr != m_bufptr)
+ {
+ // flush current buffer
+ oslFileError result = syncFile();
+ if (result != osl_File_E_None)
+ return (result);
-/****************************************************************************/
-/* osl_acquireDirectoryItem */
-/****************************************************************************/
+ if (nBytesRequested >= m_bufsiz)
+ {
+ // buffer too small, read through from file
+ sal_uInt64 uDone = 0;
+ result = readAt (nOffset, &(buffer[*pBytesRead]), nBytesRequested, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
-oslFileError osl_acquireDirectoryItem( oslDirectoryItem Item )
-{
-#ifdef _DIRENT_HAVE_D_TYPE
- oslDirectoryItemImpl* pImpl = (oslDirectoryItemImpl*) Item;
-#else
- rtl_uString* ustrFilePath = (rtl_uString *) Item;
-#endif
+ nBytesRequested -= uDone, *pBytesRead += uDone;
+ return osl_File_E_None;
+ }
- OSL_ASSERT( Item );
+ // update buffer (pointer)
+ sal_uInt64 uDone = 0;
+ result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
+ m_bufptr = bufptr, m_buflen = uDone;
+ }
+ if (bufpos >= m_buflen)
+ {
+ // end of file
+ return osl_File_E_None;
+ }
-#ifdef _DIRENT_HAVE_D_TYPE
- if( pImpl )
- oslDirectoryItemImpl_acquire( pImpl );
-#else
- if( ustrFilePath )
- rtl_uString_acquire( ustrFilePath );
-#endif
+ size_t const bytes = std::min (m_buflen - bufpos, nBytesRequested);
+ OSL_FILE_TRACE("FileHandle_Impl::readFileAt(%d, %lld, %ld)", m_fd, nOffset, bytes);
- return osl_File_E_None;
+ memcpy (&(buffer[*pBytesRead]), &(m_buffer[bufpos]), bytes);
+ nBytesRequested -= bytes, *pBytesRead += bytes, nOffset += bytes;
+ }
+ return osl_File_E_None;
+ }
}
-/****************************************************************************/
-/* osl_releaseDirectoryItem */
-/****************************************************************************/
-
-oslFileError osl_releaseDirectoryItem( oslDirectoryItem Item )
+oslFileError FileHandle_Impl::writeFileAt (
+ off_t nOffset,
+ void const * pBuffer,
+ size_t nBytesToWrite,
+ sal_uInt64 * pBytesWritten)
{
-#ifdef _DIRENT_HAVE_D_TYPE
- oslDirectoryItemImpl* pImpl = (oslDirectoryItemImpl*) Item;
-#else
- rtl_uString* ustrFilePath = (rtl_uString *) Item;
-#endif
-
- OSL_ASSERT( Item );
-
-#ifdef _DIRENT_HAVE_D_TYPE
- if( pImpl )
- oslDirectoryItemImpl_release( pImpl );
-#else
- if( ustrFilePath )
- rtl_uString_release( ustrFilePath );
-#endif
-
- return osl_File_E_None;
-}
+ if (0 == (m_state & STATE_SEEKABLE))
+ {
+ // not seekable (pipe)
+ ssize_t nBytes = ::write (m_fd, pBuffer, nBytesToWrite);
+ if (-1 == nBytes)
+ return oslTranslateFileError (OSL_FET_ERROR, errno);
+ *pBytesWritten = nBytes;
+ return osl_File_E_None;
+ }
+ else if (0 == m_buffer)
+ {
+ // not buffered
+ return writeAt (nOffset, pBuffer, nBytesToWrite, pBytesWritten);
+ }
+ else
+ {
+ sal_uInt8 const * buffer = static_cast<sal_uInt8 const *>(pBuffer);
+ for (*pBytesWritten = 0; nBytesToWrite > 0; )
+ {
+ off_t const bufptr = (nOffset / m_bufsiz) * m_bufsiz;
+ size_t const bufpos = (nOffset % m_bufsiz);
+ if (bufptr != m_bufptr)
+ {
+ // flush current buffer
+ oslFileError result = syncFile();
+ if (result != osl_File_E_None)
+ return (result);
-/****************************************************************************
- * osl_createFileHandleFromFD
- ***************************************************************************/
+ if (nBytesToWrite >= m_bufsiz)
+ {
+ // buffer to small, write through to file
+ sal_uInt64 uDone = 0;
+ result = writeAt (nOffset, &(buffer[*pBytesWritten]), nBytesToWrite, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
+ if (uDone != nBytesToWrite)
+ return osl_File_E_IO;
+
+ nBytesToWrite -= uDone, *pBytesWritten += uDone;
+ return osl_File_E_None;
+ }
-oslFileHandle osl_createFileHandleFromFD( int fd )
-{
- oslFileHandleImpl* pHandleImpl = NULL;
+ // update buffer (pointer)
+ sal_uInt64 uDone = 0;
+ result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
+ m_bufptr = bufptr, m_buflen = uDone;
+ }
- if ( fd >= 0 )
- {
- pHandleImpl = (oslFileHandleImpl*) rtl_allocateMemory( sizeof(oslFileHandleImpl) );
+ size_t const bytes = std::min (m_bufsiz - bufpos, nBytesToWrite);
+ OSL_FILE_TRACE("FileHandle_Impl::writeFileAt(%d, %lld, %ld)", m_fd, nOffset, bytes);
- if( pHandleImpl )
- {
- pHandleImpl->ustrFilePath = NULL;
- rtl_uString_new( &pHandleImpl->ustrFilePath );
- pHandleImpl->fd = fd;
+ memcpy (&(m_buffer[bufpos]), &(buffer[*pBytesWritten]), bytes);
+ nBytesToWrite -= bytes, *pBytesWritten += bytes, nOffset += bytes;
- /* FIXME: it should be detected whether the file has been locked */
- pHandleImpl->bLocked = sal_True;
+ m_buflen = std::max(m_buflen, bufpos + bytes);
+ m_state |= STATE_MODIFIED;
}
+ return osl_File_E_None;
}
-
- return (oslFileHandle)pHandleImpl;
}
-
-/****************************************************************************
- * osl_openFile
- ***************************************************************************/
-
-#ifdef HAVE_O_EXLOCK
-#define OPEN_WRITE_FLAGS ( O_RDWR | O_EXLOCK | O_NONBLOCK )
-#define OPEN_CREATE_FLAGS ( O_CREAT | O_EXCL | O_RDWR | O_EXLOCK | O_NONBLOCK )
-#else
-#define OPEN_WRITE_FLAGS ( O_RDWR )
-#define OPEN_CREATE_FLAGS ( O_CREAT | O_EXCL | O_RDWR )
-#endif
-
-oslFileError osl_openFile( rtl_uString* ustrFileURL, oslFileHandle* pHandle, sal_uInt32 uFlags )
+oslFileError FileHandle_Impl::readLineAt (
+ off_t nOffset,
+ sal_Sequence ** ppSequence,
+ sal_uInt64 * pBytesRead)
{
- oslFileHandleImpl* pHandleImpl = NULL;
- oslFileError eRet;
- rtl_uString* ustrFilePath = NULL;
+ oslFileError result = osl_File_E_None;
- char buffer[PATH_MAX];
- int fd;
- int mode = S_IRUSR | S_IRGRP | S_IROTH;
- int flags = O_RDONLY;
-
- struct flock aflock;
-
- /* locking the complete file */
- aflock.l_type = 0;
- aflock.l_whence = SEEK_SET;
- aflock.l_start = 0;
- aflock.l_len = 0;
-
- OSL_ASSERT( ustrFileURL );
- OSL_ASSERT( pHandle );
+ off_t bufptr = nOffset / m_bufsiz * m_bufsiz;
+ if (bufptr != m_bufptr)
+ {
+ /* flush current buffer */
+ result = syncFile();
+ if (result != osl_File_E_None)
+ return (result);
- if( ( 0 == ustrFileURL->length ) )
- return osl_File_E_INVAL;
+ /* update buffer (pointer) */
+ sal_uInt64 uDone = 0;
+ result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
- /* convert file URL to system path */
- eRet = osl_getSystemPathFromFileURL( ustrFileURL, &ustrFilePath );
+ m_bufptr = bufptr, m_buflen = uDone;
+ }
- if( osl_File_E_None != eRet )
- return eRet;
+ static int const LINE_STATE_BEGIN = 0;
+ static int const LINE_STATE_CR = 1;
+ static int const LINE_STATE_LF = 2;
- osl_systemPathRemoveSeparator(ustrFilePath);
+ size_t bufpos = nOffset - m_bufptr, curpos = bufpos, dstpos = 0;
+ int state = (bufpos >= m_buflen) ? LINE_STATE_LF : LINE_STATE_BEGIN;
- /* convert unicode path to text */
- if( UnicodeToText( buffer, PATH_MAX, ustrFilePath->buffer, ustrFilePath->length )
-#ifdef MACOSX
- && macxp_resolveAlias( buffer, PATH_MAX ) == 0
-#endif /* MACOSX */
- )
+ for ( ; state != LINE_STATE_LF; )
{
- /* we do not open devices or such here */
- if( !( uFlags & osl_File_OpenFlag_Create ) )
+ if (curpos >= m_buflen)
{
- struct stat aFileStat;
-
- if( 0 > stat( buffer, &aFileStat ) )
+ /* buffer examined */
+ if (0 < (curpos - bufpos))
{
- PERROR( "osl_openFile", buffer );
- eRet = oslTranslateFileError(OSL_FET_ERROR, errno );
+ /* flush buffer to sequence */
+ result = writeSequence_Impl (
+ ppSequence, &dstpos, &(m_buffer[bufpos]), curpos - bufpos);
+ if (result != osl_File_E_None)
+ return (result);
+ *pBytesRead += curpos - bufpos, nOffset += curpos - bufpos;
}
- else if( !S_ISREG( aFileStat.st_mode ) )
+ bufptr = nOffset / m_bufsiz * m_bufsiz;
+ if (bufptr != m_bufptr)
{
- eRet = osl_File_E_INVAL;
+ /* update buffer (pointer) */
+ sal_uInt64 uDone = 0;
+ result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
+ m_bufptr = bufptr, m_buflen = uDone;
}
- }
- if( osl_File_E_None == eRet )
+ bufpos = nOffset - m_bufptr, curpos = bufpos;
+ if (bufpos >= m_buflen)
+ break;
+ }
+ switch (state)
{
- /*
- * set flags and mode
- */
-
- if ( uFlags & osl_File_OpenFlag_Write )
+ case LINE_STATE_CR:
+ state = LINE_STATE_LF;
+ switch (m_buffer[curpos])
{
- mode |= S_IWUSR | S_IWGRP | S_IWOTH;
- flags = OPEN_WRITE_FLAGS;
-#ifdef MACOSX
- flags = adjustLockFlags(buffer, flags);
-#endif
- aflock.l_type = F_WRLCK;
- }
-
- if ( uFlags & osl_File_OpenFlag_Create )
- {
- mode |= S_IWUSR | S_IWGRP | S_IWOTH;
- flags = OPEN_CREATE_FLAGS;
-#ifdef MACOSX
- flags = adjustLockFlags(buffer, flags);
-#endif
+ case 0x0A: /* CRLF */
+ /* eat current char */
+ curpos++;
+ break;
+ default: /* single CR */
+ /* keep current char */
+ break;
}
-
- sal_Bool bNeedsLock = ( ( uFlags & osl_File_OpenFlag_NoLock ) == 0 );
- if ( !bNeedsLock )
+ break;
+ default:
+ /* determine next state */
+ switch (m_buffer[curpos])
{
-#ifdef MACOSX
- flags &= ~O_EXLOCK;
- flags &= ~O_SHLOCK;
-#endif
+ case 0x0A: /* single LF */
+ state = LINE_STATE_LF;
+ break;
+ case 0x0D: /* CR */
+ state = LINE_STATE_CR;
+ break;
+ default: /* advance to next char */
+ curpos++;
+ break;
}
-
- /* open the file */
- fd = open( buffer, flags, mode );
- if ( fd >= 0 )
+ if (state != LINE_STATE_BEGIN)
{
- sal_Bool bLocked = sal_False;
- if( bNeedsLock )
- {
-#ifndef HAVE_O_EXLOCK
- /* check if file lock is enabled and clear l_type member of flock otherwise */
- if( (char *) -1 == pFileLockEnvVar )
- {
- /* FIXME: this is not MT safe */
- pFileLockEnvVar = getenv("SAL_ENABLE_FILE_LOCKING");
-
- if( NULL == pFileLockEnvVar)
- pFileLockEnvVar = getenv("STAR_ENABLE_FILE_LOCKING");
- }
-#else
- /* disable range based locking */
- pFileLockEnvVar = NULL;
-
- /* remove the NONBLOCK flag again */
- flags = fcntl(fd, F_GETFL, NULL);
- flags &= ~O_NONBLOCK;
- if( 0 > fcntl(fd, F_SETFL, flags) )
- {
- close(fd);
- return oslTranslateFileError(OSL_FET_ERROR, errno);
- }
-#endif
- if( NULL == pFileLockEnvVar )
- aflock.l_type = 0;
-
- /* lock the file if flock.l_type is set */
-#ifdef MACOSX
- bLocked = ( F_WRLCK != aflock.l_type );
- if (!bLocked)
- {
- /* Mac OSX returns ENOTSUP for webdav drives. We should try read lock */
- if ( 0 == flock( fd, LOCK_EX | LOCK_NB ) || errno == ENOTSUP )
- bLocked = ( errno != ENOTSUP ) || ( 0 == flock( fd, LOCK_SH | LOCK_NB ) || errno == ENOTSUP );
- }
-#else /* MACOSX */
- bLocked = ( F_WRLCK != aflock.l_type || -1 != fcntl( fd, F_SETLK, &aflock ) );
-#endif /* MACOSX */
-
- }
-
- if ( !bNeedsLock || bLocked )
- {
- /* allocate memory for impl structure */
- pHandleImpl = (oslFileHandleImpl*) rtl_allocateMemory( sizeof(oslFileHandleImpl) );
- if( pHandleImpl )
- {
- pHandleImpl->ustrFilePath = ustrFilePath;
- pHandleImpl->fd = fd;
- pHandleImpl->bLocked = bLocked;
-
- *pHandle = (oslFileHandle) pHandleImpl;
-
- return osl_File_E_None;
- }
- else
- {
- errno = ENOMEM;
- }
- }
-
- close( fd );
+ /* store (and eat) the newline char */
+ m_buffer[curpos] = 0x0A, curpos++;
+
+ /* flush buffer to sequence */
+ result = writeSequence_Impl (
+ ppSequence, &dstpos, &(m_buffer[bufpos]), curpos - bufpos - 1);
+ if (result != osl_File_E_None)
+ return (result);
+ *pBytesRead += curpos - bufpos, nOffset += curpos - bufpos;
}
-
- PERROR( "osl_openFile", buffer );
- eRet = oslTranslateFileError(OSL_FET_ERROR, errno );
+ break;
}
}
- else
- eRet = osl_File_E_INVAL;
- rtl_uString_release( ustrFilePath );
- return eRet;
+ result = writeSequence_Impl (ppSequence, &dstpos, 0, 0);
+ if (result != osl_File_E_None)
+ return (result);
+ if (0 < dstpos)
+ return osl_File_E_None;
+ if (bufpos >= m_buflen)
+ return osl_File_E_AGAIN;
+ return osl_File_E_None;
}
-/****************************************************************************/
-/* osl_closeFile */
-/****************************************************************************/
-
-oslFileError osl_closeFile( oslFileHandle Handle )
+oslFileError FileHandle_Impl::writeSequence_Impl (
+ sal_Sequence ** ppSequence,
+ size_t * pnOffset,
+ const void * pBuffer,
+ size_t nBytes)
{
- oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl *) Handle;
- oslFileError eRet = osl_File_E_INVAL;
-
- OSL_ASSERT( Handle );
-
- if( pHandleImpl )
+ sal_Int32 nElements = *pnOffset + nBytes;
+ if (!*ppSequence)
{
- rtl_uString_release( pHandleImpl->ustrFilePath );
-
- /* release file lock if locking is enabled */
- if( pFileLockEnvVar )
- {
- struct flock aflock;
-
- aflock.l_type = F_UNLCK;
- aflock.l_whence = SEEK_SET;
- aflock.l_start = 0;
- aflock.l_len = 0;
-
- if ( pHandleImpl->bLocked )
- {
- /* FIXME: check if file is really locked ? */
-
- /* release the file share lock on this file */
-#ifdef MACOSX
- /* Mac OSX will return ENOTSUP for webdav drives. We should ignore the error */
- if ( 0 != flock( pHandleImpl->fd, LOCK_UN | LOCK_NB ) && errno != ENOTSUP )
-#else /* MACOSX */
- if( -1 == fcntl( pHandleImpl->fd, F_SETLK, &aflock ) )
-#endif /* MACOSX */
- {
- PERROR( "osl_closeFile", "unlock failed" );
- }
- }
- }
-
- if( 0 > close( pHandleImpl->fd ) )
- {
- eRet = oslTranslateFileError(OSL_FET_ERROR, errno );
- }
- else
- eRet = osl_File_E_None;
-
- rtl_freeMemory( pHandleImpl );
+ /* construct sequence */
+ rtl_byte_sequence_constructNoDefault(ppSequence, nElements);
}
-
- return eRet;
-}
-
-/****************************************************************************/
-/* osl_isEndOfFile */
-/****************************************************************************/
-
-oslFileError SAL_CALL osl_isEndOfFile( oslFileHandle Handle, sal_Bool *pIsEOF )
-{
- oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl *) Handle;
- oslFileError eRet = osl_File_E_INVAL;
-
- if ( pHandleImpl)
+ else if (nElements != (*ppSequence)->nElements)
{
- long curPos = lseek( pHandleImpl->fd, 0, SEEK_CUR );
-
- if ( curPos >= 0 )
- {
- long endPos = lseek( pHandleImpl->fd, 0, SEEK_END );
-
- if ( endPos >= 0 )
- {
- *pIsEOF = ( curPos == endPos );
- curPos = lseek( pHandleImpl->fd, curPos, SEEK_SET );
-
- if ( curPos >= 0 )
- eRet = osl_File_E_None;
- else
- eRet = oslTranslateFileError(OSL_FET_ERROR, errno );
- }
- else
- eRet = oslTranslateFileError(OSL_FET_ERROR, errno );
- }
- else
- eRet = oslTranslateFileError(OSL_FET_ERROR, errno );
+ /* resize sequence */
+ rtl_byte_sequence_realloc(ppSequence, nElements);
}
-
- return eRet;
+ if (*ppSequence != 0)
+ {
+ /* fill sequence */
+ memcpy(&((*ppSequence)->elements[*pnOffset]), pBuffer, nBytes), *pnOffset += nBytes;
+ }
+ return (*ppSequence != 0) ? osl_File_E_None : osl_File_E_NOMEM;
}
-
-/****************************************************************************/
-/* osl_moveFile */
-/****************************************************************************/
-
-oslFileError osl_moveFile( rtl_uString* ustrFileURL, rtl_uString* ustrDestURL )
+oslFileError FileHandle_Impl::syncFile()
{
- char srcPath[PATH_MAX];
- char destPath[PATH_MAX];
- oslFileError eRet;
-
- OSL_ASSERT( ustrFileURL );
- OSL_ASSERT( ustrDestURL );
-
- /* convert source url to system path */
- eRet = FileURLToPath( srcPath, PATH_MAX, ustrFileURL );
- if( eRet != osl_File_E_None )
- return eRet;
-
- /* convert destination url to system path */
- eRet = FileURLToPath( destPath, PATH_MAX, ustrDestURL );
- if( eRet != osl_File_E_None )
- return eRet;
-
-#ifdef MACOSX
- if ( macxp_resolveAlias( srcPath, PATH_MAX ) != 0 || macxp_resolveAlias( destPath, PATH_MAX ) != 0 )
- return oslTranslateFileError( OSL_FET_ERROR, errno );
-#endif/* MACOSX */
-
- return oslDoMoveFile( srcPath, destPath );
+ oslFileError result = osl_File_E_None;
+ if (m_state & STATE_MODIFIED)
+ {
+ sal_uInt64 uDone = 0;
+ result = writeAt (m_bufptr, m_buffer, m_buflen, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
+ if (uDone != m_buflen)
+ return osl_File_E_IO;
+ m_state &= ~STATE_MODIFIED;
+ }
+ return (result);
}
-/****************************************************************************/
-/* osl_copyFile */
-/****************************************************************************/
-
-oslFileError osl_copyFile( rtl_uString* ustrFileURL, rtl_uString* ustrDestURL )
+/****************************************************************************
+ * osl_createFileHandleFromFD
+ ***************************************************************************/
+extern "C" oslFileHandle osl_createFileHandleFromFD( int fd )
{
- char srcPath[PATH_MAX];
- char destPath[PATH_MAX];
- oslFileError eRet;
-
- OSL_ASSERT( ustrFileURL );
- OSL_ASSERT( ustrDestURL );
+ if (-1 == fd)
+ return 0; // EINVAL
- /* convert source url to system path */
- eRet = FileURLToPath( srcPath, PATH_MAX, ustrFileURL );
- if( eRet != osl_File_E_None )
- return eRet;
+ struct stat aFileStat;
+ if (-1 == fstat (fd, &aFileStat))
+ return 0; // EBADF
- /* convert destination url to system path */
- eRet = FileURLToPath( destPath, PATH_MAX, ustrDestURL );
- if( eRet != osl_File_E_None )
- return eRet;
+ FileHandle_Impl * pImpl = new FileHandle_Impl (fd);
+ if (0 == pImpl)
+ return 0; // ENOMEM
-#ifdef MACOSX
- if ( macxp_resolveAlias( srcPath, PATH_MAX ) != 0 || macxp_resolveAlias( destPath, PATH_MAX ) != 0 )
- return oslTranslateFileError( OSL_FET_ERROR, errno );
-#endif/* MACOSX */
+ // assume writeable
+ pImpl->m_state |= FileHandle_Impl::STATE_WRITEABLE;
+ if (!S_ISREG(aFileStat.st_mode))
+ {
+ /* not a regular file, mark not seekable */
+ pImpl->m_state &= ~FileHandle_Impl::STATE_SEEKABLE;
+ }
+ else
+ {
+ /* regular file, init current size */
+ pImpl->m_size = sal::static_int_cast< sal_uInt64 >(aFileStat.st_size);
+ }
- return osl_psz_copyFile( srcPath, destPath );
+ OSL_FILE_TRACE("osl_createFileHandleFromFD(%d, writeable) => %s",
+ pImpl->m_fd, rtl_string_getStr(pImpl->m_strFilePath));
+ return (oslFileHandle)(pImpl);
}
-/****************************************************************************/
-/* osl_removeFile */
-/****************************************************************************/
-
-oslFileError osl_removeFile( rtl_uString* ustrFileURL )
+/*******************************************************************
+ * osl_file_adjustLockFlags
+ ******************************************************************/
+static int osl_file_adjustLockFlags (const char * path, int flags)
{
- char path[PATH_MAX];
- oslFileError eRet;
-
- OSL_ASSERT( ustrFileURL );
-
- /* convert file url to system path */
- eRet = FileURLToPath( path, PATH_MAX, ustrFileURL );
- if( eRet != osl_File_E_None )
- return eRet;
-
#ifdef MACOSX
- if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
- return oslTranslateFileError( OSL_FET_ERROR, errno );
-#endif/* MACOSX */
+ /*
+ * The AFP implementation of MacOS X 10.4 treats O_EXLOCK in a way
+ * that makes it impossible for OOo to create a backup copy of the
+ * file it keeps opened. OTOH O_SHLOCK for AFP behaves as desired by
+ * the OOo file handling, so we need to check the path of the file
+ * for the filesystem name.
+ */
+ struct statfs s;
+ if( 0 <= statfs( path, &s ) )
+ {
+ if( 0 == strncmp("afpfs", s.f_fstypename, 5) )
+ {
+ flags &= ~O_EXLOCK;
+ flags |= O_SHLOCK;
+ }
+ else
+ {
+ /* Needed flags to allow opening a webdav file */
+ flags &= ~(O_EXLOCK | O_SHLOCK | O_NONBLOCK);
+ }
+ }
+#endif /* MACOSX */
- return osl_psz_removeFile( path );
+ (void) path;
+ return flags;
}
-/****************************************************************************/
-/* osl_getVolumeInformation */
-/****************************************************************************/
-
-oslFileError osl_getVolumeInformation( rtl_uString* ustrDirectoryURL, oslVolumeInfo* pInfo, sal_uInt32 uFieldMask )
+/****************************************************************************
+ * osl_file_queryLocking
+ ***************************************************************************/
+struct Locking_Impl
{
- char path[PATH_MAX];
- oslFileError eRet;
-
- OSL_ASSERT( ustrDirectoryURL );
- OSL_ASSERT( pInfo );
-
- /* convert directory url to system path */
- eRet = FileURLToPath( path, PATH_MAX, ustrDirectoryURL );
- if( eRet != osl_File_E_None )
- return eRet;
-
-#ifdef MACOSX
- if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
- return oslTranslateFileError( OSL_FET_ERROR, errno );
-#endif/* MACOSX */
-
- return osl_psz_getVolumeInformation( path, pInfo, uFieldMask);
-}
-
-/****************************************************************************/
-/* osl_createDirectory */
-/****************************************************************************/
-
-oslFileError osl_createDirectory( rtl_uString* ustrDirectoryURL )
+ int m_enabled;
+ Locking_Impl() : m_enabled(0)
+ {
+#ifndef HAVE_O_EXLOCK
+ m_enabled = ((getenv("SAL_ENABLE_FILE_LOCKING") != 0) || (getenv("STAR_ENABLE_FILE_LOCKING") != 0));
+#endif /* HAVE_O_EXLOCK */
+ }
+};
+static int osl_file_queryLocking (sal_uInt32 uFlags)
{
- char path[PATH_MAX];
- oslFileError eRet;
-
- OSL_ASSERT( ustrDirectoryURL );
-
- /* convert directory url to system path */
- eRet = FileURLToPath( path, PATH_MAX, ustrDirectoryURL );
- if( eRet != osl_File_E_None )
- return eRet;
-
-#ifdef MACOSX
- if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
- return oslTranslateFileError( OSL_FET_ERROR, errno );
-#endif/* MACOSX */
-
- return osl_psz_createDirectory( path );
+ if (!(uFlags & osl_File_OpenFlag_NoLock))
+ {
+ if ((uFlags & osl_File_OpenFlag_Write) || (uFlags & osl_File_OpenFlag_Create))
+ {
+ static Locking_Impl g_locking;
+ return (g_locking.m_enabled != 0);
+ }
+ }
+ return 0;
}
-/****************************************************************************/
-/* osl_removeDirectory */
-/****************************************************************************/
+/****************************************************************************
+ * osl_openFile
+ ***************************************************************************/
+#ifdef HAVE_O_EXLOCK
+#define OPEN_WRITE_FLAGS ( O_RDWR | O_EXLOCK | O_NONBLOCK )
+#define OPEN_CREATE_FLAGS ( O_CREAT | O_EXCL | O_RDWR | O_EXLOCK | O_NONBLOCK )
+#else
+#define OPEN_WRITE_FLAGS ( O_RDWR )
+#define OPEN_CREATE_FLAGS ( O_CREAT | O_EXCL | O_RDWR )
+#endif
-oslFileError osl_removeDirectory( rtl_uString* ustrDirectoryURL )
+oslFileError
+SAL_CALL osl_openFile( rtl_uString* ustrFileURL, oslFileHandle* pHandle, sal_uInt32 uFlags )
{
- char path[PATH_MAX];
oslFileError eRet;
- OSL_ASSERT( ustrDirectoryURL );
+ if ((ustrFileURL == 0) || (ustrFileURL->length == 0) || (pHandle == 0))
+ return osl_File_E_INVAL;
- /* convert directory url to system path */
- eRet = FileURLToPath( path, PATH_MAX, ustrDirectoryURL );
- if( eRet != osl_File_E_None )
+ /* convert file URL to system path */
+ char buffer[PATH_MAX];
+ eRet = FileURLToPath (buffer, sizeof(buffer), ustrFileURL);
+ if (eRet != osl_File_E_None)
return eRet;
-
#ifdef MACOSX
- if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
- return oslTranslateFileError( OSL_FET_ERROR, errno );
-#endif/* MACOSX */
-
- return osl_psz_removeDirectory( path );
-}
-
-//#############################################
-int path_make_parent(sal_Unicode* path)
-{
- int i = rtl_ustr_lastIndexOfChar(path, '/');
+ if (macxp_resolveAlias (buffer, sizeof(buffer)) != 0)
+ return oslTranslateFileError (OSL_FET_ERROR, errno);
+#endif /* MACOSX */
- if (i > 0)
+ /* set mode and flags */
+ int mode = S_IRUSR | S_IRGRP | S_IROTH;
+ int flags = O_RDONLY;
+ if (uFlags & osl_File_OpenFlag_Write)
{
- *(path + i) = 0;
- return i;
+ mode |= S_IWUSR | S_IWGRP | S_IWOTH;
+ flags = OPEN_WRITE_FLAGS;
+ }
+ if (uFlags & osl_File_OpenFlag_Create)
+ {
+ mode |= S_IWUSR | S_IWGRP | S_IWOTH;
+ flags = OPEN_CREATE_FLAGS;
+ }
+ if (uFlags & osl_File_OpenFlag_NoLock)
+ {
+#ifdef HAVE_O_EXLOCK
+ flags &= ~(O_EXLOCK | O_SHLOCK | O_NONBLOCK);
+#endif /* HAVE_O_EXLOCK */
}
else
- return 0;
-}
+ {
+ flags = osl_file_adjustLockFlags (buffer, flags);
+ }
-//#############################################
-int create_dir_with_callback(
- sal_Unicode* directory_path,
- oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
- void* pData)
-{
- int mode = S_IRWXU | S_IRWXG | S_IRWXO;
+ /* open the file */
+ int fd = open( buffer, flags, mode );
+ if (-1 == fd)
+ return oslTranslateFileError (OSL_FET_ERROR, errno);
- if (osl::mkdir(directory_path, mode) == 0)
+ /* reset O_NONBLOCK flag */
+ if (flags & O_NONBLOCK)
{
- if (aDirectoryCreationCallbackFunc)
+ int f = fcntl (fd, F_GETFL, 0);
+ if (-1 == f)
{
- rtl::OUString url;
- osl::FileBase::getFileURLFromSystemPath(directory_path, url);
- aDirectoryCreationCallbackFunc(pData, url.pData);
+ eRet = oslTranslateFileError (OSL_FET_ERROR, errno);
+ (void) close(fd);
+ return eRet;
+ }
+ if (-1 == fcntl (fd, F_SETFL, (f & ~O_NONBLOCK)))
+ {
+ eRet = oslTranslateFileError (OSL_FET_ERROR, errno);
+ (void) close(fd);
+ return eRet;
}
- return 0;
}
- return errno;
-}
-
-//#############################################
-oslFileError create_dir_recursively_(
- sal_Unicode* dir_path,
- oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
- void* pData)
-{
- OSL_PRECOND((rtl_ustr_getLength(dir_path) > 0) && ((dir_path + (rtl_ustr_getLength(dir_path) - 1)) != (dir_path + rtl_ustr_lastIndexOfChar(dir_path, '/'))), \
- "Path must not end with a slash");
-
- int native_err = create_dir_with_callback(
- dir_path, aDirectoryCreationCallbackFunc, pData);
-
- if (native_err == 0)
- return osl_File_E_None;
-
- if (native_err != ENOENT)
- return oslTranslateFileError(OSL_FET_ERROR, native_err);
-
- // we step back until '/a_dir' at maximum because
- // we should get an error unequal ENOENT when
- // we try to create 'a_dir' at '/' and would so
- // return before
- int pos = path_make_parent(dir_path);
-
- oslFileError osl_error = create_dir_recursively_(
- dir_path, aDirectoryCreationCallbackFunc, pData);
-
- if (osl_File_E_None != osl_error)
- return osl_error;
- dir_path[pos] = '/';
-
- return create_dir_recursively_(dir_path, aDirectoryCreationCallbackFunc, pData);
-}
-
-//#######################################
-oslFileError SAL_CALL osl_createDirectoryPath(
- rtl_uString* aDirectoryUrl,
- oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
- void* pData)
-{
- if (aDirectoryUrl == NULL)
+ /* get file status (mode, size) */
+ struct stat aFileStat;
+ if (-1 == fstat (fd, &aFileStat))
+ {
+ eRet = oslTranslateFileError (OSL_FET_ERROR, errno);
+ (void) close(fd);
+ return eRet;
+ }
+ if (!S_ISREG(aFileStat.st_mode))
+ {
+ /* we only open regular files here */
+ (void) close(fd);
return osl_File_E_INVAL;
+ }
- rtl::OUString sys_path;
- oslFileError osl_error = osl_getSystemPathFromFileURL_Ex(
- aDirectoryUrl, &sys_path.pData, sal_False);
-
- if (osl_error != osl_File_E_None)
- return osl_error;
+ if (osl_file_queryLocking (uFlags))
+ {
+#ifdef MACOSX
+ if (-1 == flock (fd, LOCK_EX | LOCK_NB))
+ {
+ /* Mac OSX returns ENOTSUP for webdav drives. We should try read lock */
+ if ((errno != ENOTSUP) || ((-1 == flock (fd, LOCK_SH | LOCK_NB)) && (errno != ENOTSUP)))
+ {
+ eRet = oslTranslateFileError (OSL_FET_ERROR, errno);
+ (void) close(fd);
+ return eRet;
+ }
+ }
+#else /* F_SETLK */
+ {
+ struct flock aflock;
- osl::systemPathRemoveSeparator(sys_path);
+ aflock.l_type = F_WRLCK;
+ aflock.l_whence = SEEK_SET;
+ aflock.l_start = 0;
+ aflock.l_len = 0;
- // const_cast because sys_path is a local copy which we want to modify inplace instead of
- // coyp it into another buffer on the heap again
- return create_dir_recursively_(sys_path.pData->buffer, aDirectoryCreationCallbackFunc, pData);
-}
+ if (-1 == fcntl (fd, F_SETLK, &aflock))
+ {
+ eRet = oslTranslateFileError (OSL_FET_ERROR, errno);
+ (void) close(fd);
+ return eRet;
+ }
+ }
+#endif /* F_SETLK */
+ }
-/****************************************************************************/
-/* osl_getCanonicalName */
-/****************************************************************************/
+ /* allocate memory for impl structure */
+ FileHandle_Impl * pImpl = new FileHandle_Impl (fd, buffer);
+ if (!pImpl)
+ {
+ eRet = oslTranslateFileError (OSL_FET_ERROR, ENOMEM);
+ (void) close(fd);
+ return eRet;
+ }
+ if (flags & O_RDWR)
+ pImpl->m_state |= FileHandle_Impl::STATE_WRITEABLE;
+ pImpl->m_size = sal::static_int_cast< sal_uInt64 >(aFileStat.st_size);
-oslFileError osl_getCanonicalName( rtl_uString* ustrFileURL, rtl_uString** pustrValidURL )
-{
- OSL_ENSURE(sal_False, "osl_getCanonicalName not implemented");
+ OSL_TRACE("osl_openFile(%d, %s) => %s", pImpl->m_fd,
+ flags & O_RDWR ? "writeable":"readonly",
+ rtl_string_getStr(pImpl->m_strFilePath));
- rtl_uString_newFromString(pustrValidURL, ustrFileURL);
+ *pHandle = (oslFileHandle)(pImpl);
return osl_File_E_None;
}
-
/****************************************************************************/
-/* osl_setFileAttributes */
+/* osl_closeFile */
/****************************************************************************/
-
-oslFileError osl_setFileAttributes( rtl_uString* ustrFileURL, sal_uInt64 uAttributes )
+oslFileError
+SAL_CALL osl_closeFile( oslFileHandle Handle )
{
- char path[PATH_MAX];
- oslFileError eRet;
+ FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle);
- OSL_ASSERT( ustrFileURL );
-
- /* convert file url to system path */
- eRet = FileURLToPath( path, PATH_MAX, ustrFileURL );
- if( eRet != osl_File_E_None )
- return eRet;
+ if ((pImpl == 0) || (pImpl->m_fd < 0))
+ return osl_File_E_INVAL;
-#ifdef MACOSX
- if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
- return oslTranslateFileError( OSL_FET_ERROR, errno );
-#endif/* MACOSX */
+ /* close(2) implicitly (and unconditionally) unlocks */
+ OSL_TRACE("osl_closeFile(%d) => %s", pImpl->m_fd, rtl_string_getStr(pImpl->m_strFilePath));
+ oslFileError result = pImpl->syncFile();
+ if (result != osl_File_E_None)
+ {
+ /* close, ignoring double failure */
+ (void) close (pImpl->m_fd);
+ }
+ else if (-1 == close (pImpl->m_fd))
+ {
+ /* translate error code */
+ result = oslTranslateFileError (OSL_FET_ERROR, errno);
+ }
- return osl_psz_setFileAttributes( path, uAttributes );
+ delete pImpl;
+ return (result);
}
-/****************************************************************************/
-/* osl_setFileTime */
-/****************************************************************************/
-
-oslFileError osl_setFileTime( rtl_uString* ustrFileURL, const TimeValue* pCreationTime,
- const TimeValue* pLastAccessTime, const TimeValue* pLastWriteTime )
+/************************************************
+ * osl_syncFile
+ ***********************************************/
+oslFileError
+SAL_CALL osl_syncFile(oslFileHandle Handle)
{
- char path[PATH_MAX];
- oslFileError eRet;
+ FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle);
- OSL_ASSERT( ustrFileURL );
-
- /* convert file url to system path */
- eRet = FileURLToPath( path, PATH_MAX, ustrFileURL );
- if( eRet != osl_File_E_None )
- return eRet;
+ if ((0 == pImpl) || (-1 == pImpl->m_fd))
+ return osl_File_E_INVAL;
-#ifdef MACOSX
- if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
- return oslTranslateFileError( OSL_FET_ERROR, errno );
-#endif/* MACOSX */
+ OSL_FILE_TRACE("osl_syncFile(%d)", pImpl->m_fd);
+ oslFileError result = pImpl->syncFile();
+ if (result != osl_File_E_None)
+ return (result);
+ if (-1 == fsync (pImpl->m_fd))
+ return oslTranslateFileError (OSL_FET_ERROR, errno);
- return osl_psz_setFileTime( path, pCreationTime, pLastAccessTime, pLastWriteTime );
+ return osl_File_E_None;
}
-/******************************************************************************
- *
- * Exported Module Functions
- * (independent of C or Unicode Strings)
- *
- *****************************************************************************/
-
/*******************************************
osl_mapFile
********************************************/
@@ -1244,9 +957,9 @@ SAL_CALL osl_mapFile (
sal_uInt32 uFlags
)
{
- oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl*)Handle;
+ FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pHandleImpl) || (-1 == pHandleImpl->fd) || (0 == ppAddr))
+ if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == ppAddr))
return osl_File_E_INVAL;
*ppAddr = 0;
@@ -1260,7 +973,7 @@ SAL_CALL osl_mapFile (
return osl_File_E_OVERFLOW;
off_t const nOffset = sal::static_int_cast< off_t >(uOffset);
- void* p = mmap(NULL, nLength, PROT_READ, MAP_SHARED, pHandleImpl->fd, nOffset);
+ void* p = mmap(NULL, nLength, PROT_READ, MAP_SHARED, pImpl->m_fd, nOffset);
if (MAP_FAILED == p)
return oslTranslateFileError(OSL_FET_ERROR, errno);
*ppAddr = p;
@@ -1268,11 +981,7 @@ SAL_CALL osl_mapFile (
if (uFlags & osl_File_MapFlag_RandomAccess)
{
// Determine memory pagesize.
-#if defined(FREEBSD) || defined(NETBSD) || defined(MACOSX)
- size_t const nPageSize = getpagesize();
-#else /* POSIX */
- size_t const nPageSize = sysconf(_SC_PAGESIZE);
-#endif /* xBSD || POSIX */
+ size_t const nPageSize = FileHandle_Impl::getpagesize();
if (size_t(-1) != nPageSize)
{
/*
@@ -1321,64 +1030,83 @@ SAL_CALL osl_unmapFile (void* pAddr, sal_uInt64 uLength)
}
/*******************************************
- osl_readFile
+ osl_readLine
********************************************/
-
-oslFileError osl_readFile(oslFileHandle Handle, void* pBuffer, sal_uInt64 uBytesRequested, sal_uInt64* pBytesRead)
+oslFileError
+SAL_CALL osl_readLine (
+ oslFileHandle Handle,
+ sal_Sequence ** ppSequence)
{
- ssize_t nBytes = 0;
- oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl*)Handle;
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pHandleImpl) || (pHandleImpl->fd < 0) || (0 == pBuffer) || (0 == pBytesRead))
+ if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == ppSequence))
return osl_File_E_INVAL;
+ sal_uInt64 uBytesRead = 0;
- nBytes = read(
- pHandleImpl->fd, pBuffer,
- ((uBytesRequested
- <= static_cast< size_t >(std::numeric_limits< ssize_t >::max()))
- ? static_cast< size_t >(uBytesRequested)
- : static_cast< size_t >(std::numeric_limits< ssize_t >::max())));
-
- if (-1 == nBytes)
- return oslTranslateFileError(OSL_FET_ERROR, errno);
-
- *pBytesRead = nBytes;
- return osl_File_E_None;
+ // read at current fileptr; fileptr += uBytesRead;
+ oslFileError result = pImpl->readLineAt (
+ pImpl->m_fileptr, ppSequence, &uBytesRead);
+ if (result == osl_File_E_None)
+ pImpl->m_fileptr += uBytesRead;
+ return (result);
}
/*******************************************
- osl_writeFile
+ osl_readFile
********************************************/
-
-oslFileError osl_writeFile(oslFileHandle Handle, const void* pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64* pBytesWritten)
+oslFileError
+SAL_CALL osl_readFile (
+ oslFileHandle Handle,
+ void * pBuffer,
+ sal_uInt64 uBytesRequested,
+ sal_uInt64 * pBytesRead)
{
- ssize_t nBytes = 0;
- oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl*)Handle;
-
- OSL_ASSERT(pHandleImpl);
- OSL_ASSERT(pBuffer);
- OSL_ASSERT(pBytesWritten);
+ FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pHandleImpl) || (0 == pBuffer) || (0 == pBytesWritten))
+ if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pBuffer) || (0 == pBytesRead))
return osl_File_E_INVAL;
- OSL_ASSERT(pHandleImpl->fd >= 0);
+ static sal_uInt64 const g_limit_ssize_t = std::numeric_limits< ssize_t >::max();
+ if (g_limit_ssize_t < uBytesRequested)
+ return osl_File_E_OVERFLOW;
+ size_t const nBytesRequested = sal::static_int_cast< size_t >(uBytesRequested);
- if (pHandleImpl->fd < 0)
- return osl_File_E_INVAL;
+ // read at current fileptr; fileptr += *pBytesRead;
+ oslFileError result = pImpl->readFileAt (
+ pImpl->m_fileptr, pBuffer, nBytesRequested, pBytesRead);
+ if (result == osl_File_E_None)
+ pImpl->m_fileptr += *pBytesRead;
+ return (result);
+}
- nBytes = write(
- pHandleImpl->fd, pBuffer,
- ((uBytesToWrite
- <= static_cast< size_t >(std::numeric_limits< ssize_t >::max()))
- ? static_cast< size_t >(uBytesToWrite)
- : static_cast< size_t >(std::numeric_limits< ssize_t >::max())));
+/*******************************************
+ osl_writeFile
+********************************************/
+oslFileError
+SAL_CALL osl_writeFile (
+ oslFileHandle Handle,
+ const void * pBuffer,
+ sal_uInt64 uBytesToWrite,
+ sal_uInt64 * pBytesWritten)
+{
+ FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle);
- if (-1 == nBytes)
- return oslTranslateFileError(OSL_FET_ERROR, errno);
+ if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pBuffer) || (0 == pBytesWritten))
+ return osl_File_E_INVAL;
+ if (0 == (pImpl->m_state & FileHandle_Impl::STATE_WRITEABLE))
+ return osl_File_E_BADF;
- *pBytesWritten = nBytes;
- return osl_File_E_None;
+ static sal_uInt64 const g_limit_ssize_t = std::numeric_limits< ssize_t >::max();
+ if (g_limit_ssize_t < uBytesToWrite)
+ return osl_File_E_OVERFLOW;
+ size_t const nBytesToWrite = sal::static_int_cast< size_t >(uBytesToWrite);
+
+ // write at current fileptr; fileptr += *pBytesWritten;
+ oslFileError result = pImpl->writeFileAt (
+ pImpl->m_fileptr, pBuffer, nBytesToWrite, pBytesWritten);
+ if (result == osl_File_E_None)
+ pImpl->m_fileptr += *pBytesWritten;
+ return (result);
}
/*******************************************
@@ -1392,10 +1120,12 @@ SAL_CALL osl_readFileAt (
sal_uInt64 uBytesRequested,
sal_uInt64* pBytesRead)
{
- oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl*)Handle;
+ FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pHandleImpl) || (pHandleImpl->fd < 0) || (0 == pBuffer) || (0 == pBytesRead))
+ if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pBuffer) || (0 == pBytesRead))
return osl_File_E_INVAL;
+ if (0 == (pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE))
+ return osl_File_E_SPIPE;
static sal_uInt64 const g_limit_off_t = std::numeric_limits< off_t >::max();
if (g_limit_off_t < uOffset)
@@ -1407,35 +1137,8 @@ SAL_CALL osl_readFileAt (
return osl_File_E_OVERFLOW;
size_t const nBytesRequested = sal::static_int_cast< size_t >(uBytesRequested);
-#if defined(LINUX) || defined(SOLARIS)
-
- ssize_t nBytes = ::pread(pHandleImpl->fd, pBuffer, nBytesRequested, nOffset);
- if ((-1 == nBytes) && (EOVERFLOW == errno))
- {
- /*
- * Workaround for 'pread()' failure at end-of-file:
- *
- * Some 'pread()'s fail with EOVERFLOW when reading at (or past)
- * end-of-file, different from 'lseek() + read()' behaviour.
- * Returning '0 bytes read' and 'osl_File_E_None' instead.
- */
- nBytes = 0;
- }
-
-#else /* LINUX || SOLARIS */
-
- if (-1 == ::lseek (pHandleImpl->fd, nOffset, SEEK_SET))
- return oslTranslateFileError(OSL_FET_ERROR, errno);
-
- ssize_t nBytes = ::read(pHandleImpl->fd, pBuffer, nBytesRequested);
-
-#endif /* LINUX || SOLARIS */
-
- if (-1 == nBytes)
- return oslTranslateFileError(OSL_FET_ERROR, errno);
-
- *pBytesRead = nBytes;
- return osl_File_E_None;
+ // read at specified fileptr
+ return pImpl->readFileAt (nOffset, pBuffer, nBytesRequested, pBytesRead);
}
/*******************************************
@@ -1449,10 +1152,14 @@ SAL_CALL osl_writeFileAt (
sal_uInt64 uBytesToWrite,
sal_uInt64* pBytesWritten)
{
- oslFileHandleImpl* pHandleImpl = (oslFileHandleImpl*)Handle;
+ FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ((0 == pHandleImpl) || (pHandleImpl->fd < 0) || (0 == pBuffer) || (0 == pBytesWritten))
+ if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pBuffer) || (0 == pBytesWritten))
return osl_File_E_INVAL;
+ if (0 == (pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE))
+ return osl_File_E_SPIPE;
+ if (0 == (pImpl->m_state & FileHandle_Impl::STATE_WRITEABLE))
+ return osl_File_E_BADF;
static sal_uInt64 const g_limit_off_t = std::numeric_limits< off_t >::max();
if (g_limit_off_t < uOffset)
@@ -1464,189 +1171,141 @@ SAL_CALL osl_writeFileAt (
return osl_File_E_OVERFLOW;
size_t const nBytesToWrite = sal::static_int_cast< size_t >(uBytesToWrite);
-#if defined(LINUX) || defined(SOLARIS)
-
- ssize_t nBytes = ::pwrite(pHandleImpl->fd, pBuffer, nBytesToWrite, nOffset);
+ // write at specified fileptr
+ return pImpl->writeFileAt (nOffset, pBuffer, nBytesToWrite, pBytesWritten);
+}
-#else /* LINUX || SOLARIS */
+/****************************************************************************/
+/* osl_isEndOfFile */
+/****************************************************************************/
+oslFileError
+SAL_CALL osl_isEndOfFile( oslFileHandle Handle, sal_Bool *pIsEOF )
+{
+ FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle);
- if (-1 == ::lseek(pHandleImpl->fd, nOffset, SEEK_SET))
- return oslTranslateFileError(OSL_FET_ERROR, errno);
+ if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pIsEOF))
+ return osl_File_E_INVAL;
- ssize_t nBytes = ::write(pHandleImpl->fd, pBuffer, nBytesToWrite);
+ *pIsEOF = (pImpl->getPos() == pImpl->getSize());
+ return osl_File_E_None;
+}
-#endif /* LINUX || SOLARIS */
+/************************************************
+ * osl_getFilePos
+ ***********************************************/
+oslFileError
+SAL_CALL osl_getFilePos( oslFileHandle Handle, sal_uInt64* pPos )
+{
+ FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle);
- if (-1 == nBytes)
- return oslTranslateFileError(OSL_FET_ERROR, errno);
+ if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pPos))
+ return osl_File_E_INVAL;
- *pBytesWritten = nBytes;
+ *pPos = pImpl->getPos();
return osl_File_E_None;
}
/*******************************************
osl_setFilePos
********************************************/
-
-oslFileError osl_setFilePos( oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos )
+oslFileError
+SAL_CALL osl_setFilePos (oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uOffset)
{
- oslFileHandleImpl* pHandleImpl=0;
- int nRet=0;
- off_t nOffset=0;
-
- pHandleImpl = (oslFileHandleImpl*) Handle;
- if ( pHandleImpl == 0 )
- {
- return osl_File_E_INVAL;
- }
+ FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ( pHandleImpl->fd < 0 )
- {
+ if ((0 == pImpl) || (-1 == pImpl->m_fd))
return osl_File_E_INVAL;
- }
- /* FIXME mfe: setFilePos: Do we have any runtime function to determine LONG_MAX? */
- if ( uPos > LONG_MAX )
- {
+ static sal_Int64 const g_limit_off_t = std::numeric_limits< off_t >::max();
+ if (g_limit_off_t < uOffset)
return osl_File_E_OVERFLOW;
- }
-
- nOffset=(off_t)uPos;
+ off_t nPos = 0, nOffset = sal::static_int_cast< off_t >(uOffset);
switch(uHow)
{
case osl_Pos_Absolut:
- nOffset = lseek(pHandleImpl->fd,nOffset,SEEK_SET);
+ if (0 > nOffset)
+ return osl_File_E_INVAL;
break;
case osl_Pos_Current:
- nOffset = lseek(pHandleImpl->fd,nOffset,SEEK_CUR);
+ nPos = sal::static_int_cast< off_t >(pImpl->getPos());
+ if ((0 > nOffset) && (-1*nOffset > nPos))
+ return osl_File_E_INVAL;
+ if (g_limit_off_t < nPos + nOffset)
+ return osl_File_E_OVERFLOW;
break;
case osl_Pos_End:
- nOffset = lseek(pHandleImpl->fd,nOffset,SEEK_END);
+ nPos = sal::static_int_cast< off_t >(pImpl->getSize());
+ if ((0 > nOffset) && (-1*nOffset > nPos))
+ return osl_File_E_INVAL;
+ if (g_limit_off_t < nPos + nOffset)
+ return osl_File_E_OVERFLOW;
break;
default:
return osl_File_E_INVAL;
}
- if ( nOffset < 0 )
- {
- nRet=errno;
- return oslTranslateFileError(OSL_FET_ERROR, nRet);
- }
-
- return osl_File_E_None;
-}
-
-/************************************************
- * osl_getFilePos
- ***********************************************/
-
-oslFileError osl_getFilePos( oslFileHandle Handle, sal_uInt64* pPos )
-{
- oslFileHandleImpl* pHandleImpl=0;
- off_t nOffset=0;
- int nRet=0;
-
- pHandleImpl = (oslFileHandleImpl*) Handle;
- if ( pHandleImpl == 0 || pPos == 0)
- {
- return osl_File_E_INVAL;
- }
-
- if ( pHandleImpl->fd < 0 )
- {
- return osl_File_E_INVAL;
- }
-
- nOffset = lseek(pHandleImpl->fd,0,SEEK_CUR);
-
- if (nOffset < 0)
- {
- nRet =errno;
-
- /* *pPos =0; */
-
- return oslTranslateFileError(OSL_FET_ERROR, nRet);
- }
-
- *pPos=nOffset;
-
- return osl_File_E_None;
+ return pImpl->setPos (nPos + nOffset);
}
/****************************************************************************
* osl_getFileSize
****************************************************************************/
-
-oslFileError osl_getFileSize( oslFileHandle Handle, sal_uInt64* pSize )
+oslFileError
+SAL_CALL osl_getFileSize( oslFileHandle Handle, sal_uInt64* pSize )
{
- oslFileHandleImpl* pHandleImpl=(oslFileHandleImpl*) Handle;
- if (pHandleImpl == 0)
- return osl_File_E_INVAL;
+ FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle);
- struct stat file_stat;
- if (fstat(pHandleImpl->fd, &file_stat) == -1)
- return oslTranslateFileError(OSL_FET_ERROR, errno);
+ if ((0 == pImpl) || (-1 == pImpl->m_fd) || (0 == pSize))
+ return osl_File_E_INVAL;
- *pSize = file_stat.st_size;
+ *pSize = pImpl->getSize();
return osl_File_E_None;
}
/************************************************
* osl_setFileSize
***********************************************/
-
-oslFileError osl_setFileSize( oslFileHandle Handle, sal_uInt64 uSize )
+oslFileError
+SAL_CALL osl_setFileSize( oslFileHandle Handle, sal_uInt64 uSize )
{
- oslFileHandleImpl* pHandleImpl=0;
- off_t nOffset=0;
-
- pHandleImpl = (oslFileHandleImpl*) Handle;
- if ( pHandleImpl == 0 )
- {
- return osl_File_E_INVAL;
- }
+ FileHandle_Impl* pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ( pHandleImpl->fd < 0 )
- {
+ if ((0 == pImpl) || (-1 == pImpl->m_fd))
return osl_File_E_INVAL;
- }
+ if (0 == (pImpl->m_state & FileHandle_Impl::STATE_WRITEABLE))
+ return osl_File_E_BADF;
- /* FIXME: mfe: setFileSize: Do we have any runtime function to determine LONG_MAX? */
- if ( uSize > LONG_MAX )
- {
+ static sal_uInt64 const g_limit_off_t = std::numeric_limits< off_t >::max();
+ if (g_limit_off_t < uSize)
return osl_File_E_OVERFLOW;
- }
+ off_t const nSize = sal::static_int_cast< off_t >(uSize);
+
+ oslFileError result = pImpl->syncFile();
+ if (result != osl_File_E_None)
+ return (result);
- nOffset = (off_t)uSize;
- if (ftruncate (pHandleImpl->fd, nOffset) < 0)
+ if (-1 == ftruncate (pImpl->m_fd, nSize))
{
/* Failure. Try fallback algorithm */
- oslFileError result;
- struct stat aStat;
- off_t nCurPos;
+ off_t nCurPos;
/* Save original result */
result = oslTranslateFileError (OSL_FET_ERROR, errno);
PERROR("ftruncate", "Try osl_setFileSize [fallback]\n");
/* Check against current size. Fail upon 'shrink' */
- if (fstat (pHandleImpl->fd, &aStat) < 0)
- {
- PERROR("ftruncate: fstat", "Out osl_setFileSize [error]\n");
- return (result);
- }
- if ((0 <= nOffset) && (nOffset <= aStat.st_size))
+ if (uSize <= pImpl->getSize())
{
/* Failure upon 'shrink'. Return original result */
return (result);
}
- /* Save current position */
- nCurPos = (off_t)lseek (pHandleImpl->fd, (off_t)0, SEEK_CUR);
+ /* Save current position *//* @@@ pImpl->m_offset @@@ */
+ nCurPos = (off_t)lseek (pImpl->m_fd, (off_t)0, SEEK_CUR);
if (nCurPos == (off_t)(-1))
{
PERROR("ftruncate: lseek", "Out osl_setFileSize [error]\n");
@@ -1654,2095 +1313,31 @@ oslFileError osl_setFileSize( oslFileHandle Handle, sal_uInt64 uSize )
}
/* Try 'expand' via 'lseek()' and 'write()' */
- if (lseek (pHandleImpl->fd, (off_t)(nOffset - 1), SEEK_SET) < 0)
+ if (lseek (pImpl->m_fd, (off_t)(nSize - 1), SEEK_SET) < 0)
{
PERROR("ftruncate: lseek", "Out osl_setFileSize [error]\n");
return (result);
}
- if (write (pHandleImpl->fd, (char*)"", (size_t)1) < 0)
+ if (write (pImpl->m_fd, (char*)"", (size_t)1) < 0)
{
/* Failure. Restore saved position */
PERROR("ftruncate: write", "Out osl_setFileSize [error]\n");
- if (lseek (pHandleImpl->fd, (off_t)nCurPos, SEEK_SET) < 0)
+ if (lseek (pImpl->m_fd, (off_t)nCurPos, SEEK_SET) < 0)
{
-#ifdef DEBUG_OSL_FILE
- perror("ftruncate: lseek");
-#endif /* DEBUG_OSL_FILE */
+ PERROR("ftruncate: lseek", "ignoring");
}
return (result);
}
/* Success. Restore saved position */
- if (lseek (pHandleImpl->fd, (off_t)nCurPos, SEEK_SET) < 0)
+ if (lseek (pImpl->m_fd, (off_t)nCurPos, SEEK_SET) < 0)
{
PERROR("ftruncate: lseek", "Out osl_setFileSize [error]");
return (result);
}
}
- return (osl_File_E_None);
-}
-
-/*###############################################*/
-oslFileError SAL_CALL osl_syncFile(oslFileHandle Handle)
-{
- oslFileHandleImpl* handle_impl = (oslFileHandleImpl*)Handle;
-
- if (handle_impl == 0)
- return osl_File_E_INVAL;
-
- if (fsync(handle_impl->fd) == -1)
- return oslTranslateFileError(OSL_FET_ERROR, errno);
-
- return osl_File_E_None;
-}
-
-/******************************************************************************
- *
- * C-String Versions of Exported Module Functions
- *
- *****************************************************************************/
-
-#ifdef HAVE_STATFS_H
-
-#if defined(FREEBSD) || defined(NETBSD) || defined(MACOSX)
-# define __OSL_STATFS_STRUCT struct statfs
-# define __OSL_STATFS(dir, sfs) statfs((dir), (sfs))
-# define __OSL_STATFS_BLKSIZ(a) ((sal_uInt64)((a).f_bsize))
-# define __OSL_STATFS_TYPENAME(a) ((a).f_fstypename)
-# define __OSL_STATFS_ISREMOTE(a) (((a).f_type & MNT_LOCAL) == 0)
-
-/* always return true if queried for the properties of
- the file system. If you think this is wrong under any
- of the target platforms fix it!!!! */
-# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) (1)
-# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) (1)
-#endif /* FREEBSD || NETBSD || MACOSX */
-
-#if defined(LINUX)
-# define __OSL_NFS_SUPER_MAGIC 0x6969
-# define __OSL_SMB_SUPER_MAGIC 0x517B
-# define __OSL_MSDOS_SUPER_MAGIC 0x4d44
-# define __OSL_NTFS_SUPER_MAGIC 0x5346544e
-# define __OSL_STATFS_STRUCT struct statfs
-# define __OSL_STATFS(dir, sfs) statfs((dir), (sfs))
-# define __OSL_STATFS_BLKSIZ(a) ((sal_uInt64)((a).f_bsize))
-# define __OSL_STATFS_IS_NFS(a) (__OSL_NFS_SUPER_MAGIC == (a).f_type)
-# define __OSL_STATFS_IS_SMB(a) (__OSL_SMB_SUPER_MAGIC == (a).f_type)
-# define __OSL_STATFS_ISREMOTE(a) (__OSL_STATFS_IS_NFS((a)) || __OSL_STATFS_IS_SMB((a)))
-# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) ((__OSL_MSDOS_SUPER_MAGIC != (a).f_type) && (__OSL_NTFS_SUPER_MAGIC != (a).f_type))
-# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) ((__OSL_MSDOS_SUPER_MAGIC != (a).f_type))
-#endif /* LINUX */
-
-#if defined(SOLARIS) || defined(IRIX)
-# define __OSL_STATFS_STRUCT struct statvfs
-# define __OSL_STATFS(dir, sfs) statvfs((dir), (sfs))
-# define __OSL_STATFS_BLKSIZ(a) ((sal_uInt64)((a).f_frsize))
-# define __OSL_STATFS_TYPENAME(a) ((a).f_basetype)
-# define __OSL_STATFS_ISREMOTE(a) (rtl_str_compare((a).f_basetype, "nfs") == 0)
-
-/* always return true if queried for the properties of
- the file system. If you think this is wrong under any
- of the target platforms fix it!!!! */
-# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) (1)
-# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) (1)
-#endif /* SOLARIS || IRIX*/
-
-# define __OSL_STATFS_INIT(a) (memset(&(a), 0, sizeof(__OSL_STATFS_STRUCT)))
-
-#else /* no statfs available */
-
-# define __OSL_STATFS_STRUCT struct dummy {int i;}
-# define __OSL_STATFS_INIT(a) ((void)0)
-# define __OSL_STATFS(dir, sfs) (1)
-# define __OSL_STATFS_ISREMOTE(sfs) (0)
-# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) (1)
-# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) (1)
-#endif /* HAVE_STATFS_H */
-
-
-static oslFileError osl_psz_getVolumeInformation (
- const sal_Char* pszDirectory, oslVolumeInfo* pInfo, sal_uInt32 uFieldMask)
-{
- __OSL_STATFS_STRUCT sfs;
-
- if (!pInfo)
- return osl_File_E_INVAL;
-
- __OSL_STATFS_INIT(sfs);
-
- pInfo->uValidFields = 0;
- pInfo->uAttributes = 0;
-
- if ((__OSL_STATFS(pszDirectory, &sfs)) < 0)
- {
- oslFileError result = oslTranslateFileError(OSL_FET_ERROR, errno);
- return (result);
- }
-
- /* FIXME: how to detect the kind of storage (fixed, cdrom, ...) */
- if (uFieldMask & osl_VolumeInfo_Mask_Attributes)
- {
- if (__OSL_STATFS_ISREMOTE(sfs))
- pInfo->uAttributes |= osl_Volume_Attribute_Remote;
-
- pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes;
- }
-
- if (uFieldMask & osl_VolumeInfo_Mask_FileSystemCaseHandling)
- {
- if (__OSL_STATFS_IS_CASE_SENSITIVE_FS(sfs))
- pInfo->uAttributes |= osl_Volume_Attribute_Case_Sensitive;
-
- if (__OSL_STATFS_IS_CASE_PRESERVING_FS(sfs))
- pInfo->uAttributes |= osl_Volume_Attribute_Case_Is_Preserved;
-
- pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes;
- }
-
- pInfo->uTotalSpace = 0;
- pInfo->uFreeSpace = 0;
- pInfo->uUsedSpace = 0;
-
-#if defined(__OSL_STATFS_BLKSIZ)
-
- if ((uFieldMask & osl_VolumeInfo_Mask_TotalSpace) ||
- (uFieldMask & osl_VolumeInfo_Mask_UsedSpace))
- {
- pInfo->uTotalSpace = __OSL_STATFS_BLKSIZ(sfs);
- pInfo->uTotalSpace *= (sal_uInt64)(sfs.f_blocks);
- pInfo->uValidFields |= osl_VolumeInfo_Mask_TotalSpace;
- }
-
- if ((uFieldMask & osl_VolumeInfo_Mask_FreeSpace) ||
- (uFieldMask & osl_VolumeInfo_Mask_UsedSpace))
- {
- pInfo->uFreeSpace = __OSL_STATFS_BLKSIZ(sfs);
-
- if (getuid() == 0)
- pInfo->uFreeSpace *= (sal_uInt64)(sfs.f_bfree);
- else
- pInfo->uFreeSpace *= (sal_uInt64)(sfs.f_bavail);
-
- pInfo->uValidFields |= osl_VolumeInfo_Mask_FreeSpace;
- }
-
-#endif /* __OSL_STATFS_BLKSIZ */
-
- if ((pInfo->uValidFields & osl_VolumeInfo_Mask_TotalSpace) &&
- (pInfo->uValidFields & osl_VolumeInfo_Mask_FreeSpace ))
- {
- pInfo->uUsedSpace = pInfo->uTotalSpace - pInfo->uFreeSpace;
- pInfo->uValidFields |= osl_VolumeInfo_Mask_UsedSpace;
- }
-
- pInfo->uMaxNameLength = 0;
- if (uFieldMask & osl_VolumeInfo_Mask_MaxNameLength)
- {
- long nLen = pathconf(pszDirectory, _PC_NAME_MAX);
- if (nLen > 0)
- {
- pInfo->uMaxNameLength = (sal_uInt32)nLen;
- pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxNameLength;
- }
- }
-
- pInfo->uMaxPathLength = 0;
- if (uFieldMask & osl_VolumeInfo_Mask_MaxPathLength)
- {
- long nLen = pathconf (pszDirectory, _PC_PATH_MAX);
- if (nLen > 0)
- {
- pInfo->uMaxPathLength = (sal_uInt32)nLen;
- pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxPathLength;
- }
- }
-
-#if defined(__OSL_STATFS_TYPENAME)
-
- if (uFieldMask & osl_VolumeInfo_Mask_FileSystemName)
- {
- rtl_string2UString(
- &(pInfo->ustrFileSystemName),
- __OSL_STATFS_TYPENAME(sfs),
- rtl_str_getLength(__OSL_STATFS_TYPENAME(sfs)),
- osl_getThreadTextEncoding(),
- OUSTRING_TO_OSTRING_CVTFLAGS);
- OSL_ASSERT(pInfo->ustrFileSystemName != 0);
-
- pInfo->uValidFields |= osl_VolumeInfo_Mask_FileSystemName;
- }
-
-#endif /* __OSL_STATFS_TYPENAME */
-
- if (uFieldMask & osl_VolumeInfo_Mask_DeviceHandle)
- {
- /* FIXME: check also entries in mntent for the device
- and fill it with correct values */
-
- *pInfo->pDeviceHandle = osl_isFloppyDrive(pszDirectory);
-
- if (*pInfo->pDeviceHandle)
- {
- pInfo->uValidFields |= osl_VolumeInfo_Mask_DeviceHandle;
- pInfo->uAttributes |= osl_Volume_Attribute_Removeable;
- pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes;
- }
- }
+ OSL_FILE_TRACE("osl_setFileSize(%d, %lld) => %ld", pImpl->m_fd, pImpl->getSize(), nSize);
+ pImpl->m_size = sal::static_int_cast< sal_uInt64 >(nSize);
return osl_File_E_None;
}
-
-/*************************************
- * osl_psz_setFileAttributes
- ************************************/
-
-static oslFileError osl_psz_setFileAttributes( const sal_Char* pszFilePath, sal_uInt64 uAttributes )
-{
- oslFileError osl_error = osl_File_E_None;
- mode_t nNewMode = 0;
-
- OSL_ENSURE(!(osl_File_Attribute_Hidden & uAttributes), "osl_File_Attribute_Hidden doesn't work under Unix");
-
- if (uAttributes & osl_File_Attribute_OwnRead)
- nNewMode |= S_IRUSR;
-
- if (uAttributes & osl_File_Attribute_OwnWrite)
- nNewMode|=S_IWUSR;
-
- if (uAttributes & osl_File_Attribute_OwnExe)
- nNewMode|=S_IXUSR;
-
- if (uAttributes & osl_File_Attribute_GrpRead)
- nNewMode|=S_IRGRP;
-
- if (uAttributes & osl_File_Attribute_GrpWrite)
- nNewMode|=S_IWGRP;
-
- if (uAttributes & osl_File_Attribute_GrpExe)
- nNewMode|=S_IXGRP;
-
- if (uAttributes & osl_File_Attribute_OthRead)
- nNewMode|=S_IROTH;
-
- if (uAttributes & osl_File_Attribute_OthWrite)
- nNewMode|=S_IWOTH;
-
- if (uAttributes & osl_File_Attribute_OthExe)
- nNewMode|=S_IXOTH;
-
- if (chmod(pszFilePath, nNewMode) < 0)
- osl_error = oslTranslateFileError(OSL_FET_ERROR, errno);
-
- return osl_error;
-}
-
-/******************************************
- * osl_psz_setFileTime
- *****************************************/
-
-static oslFileError osl_psz_setFileTime( const sal_Char* pszFilePath,
- const TimeValue* /*pCreationTime*/,
- const TimeValue* pLastAccessTime,
- const TimeValue* pLastWriteTime )
-{
- int nRet=0;
- struct utimbuf aTimeBuffer;
- struct stat aFileStat;
-#ifdef DEBUG_OSL_FILE
- struct tm* pTM=0;
-#endif
-
- nRet = lstat(pszFilePath,&aFileStat);
-
- if ( nRet < 0 )
- {
- nRet=errno;
- return oslTranslateFileError(OSL_FET_ERROR, nRet);
- }
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"File Times are (in localtime):\n");
- pTM=localtime(&aFileStat.st_ctime);
- fprintf(stderr,"CreationTime is '%s'\n",asctime(pTM));
- pTM=localtime(&aFileStat.st_atime);
- fprintf(stderr,"AccessTime is '%s'\n",asctime(pTM));
- pTM=localtime(&aFileStat.st_mtime);
- fprintf(stderr,"Modification is '%s'\n",asctime(pTM));
-
- fprintf(stderr,"File Times are (in UTC):\n");
- fprintf(stderr,"CreationTime is '%s'\n",ctime(&aFileStat.st_ctime));
- fprintf(stderr,"AccessTime is '%s'\n",ctime(&aTimeBuffer.actime));
- fprintf(stderr,"Modification is '%s'\n",ctime(&aTimeBuffer.modtime));
-#endif
-
- if ( pLastAccessTime != 0 )
- {
- aTimeBuffer.actime=pLastAccessTime->Seconds;
- }
- else
- {
- aTimeBuffer.actime=aFileStat.st_atime;
- }
-
- if ( pLastWriteTime != 0 )
- {
- aTimeBuffer.modtime=pLastWriteTime->Seconds;
- }
- else
- {
- aTimeBuffer.modtime=aFileStat.st_mtime;
- }
-
- /* mfe: Creation time not used here! */
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"File Times are (in localtime):\n");
- pTM=localtime(&aFileStat.st_ctime);
- fprintf(stderr,"CreationTime now '%s'\n",asctime(pTM));
- pTM=localtime(&aTimeBuffer.actime);
- fprintf(stderr,"AccessTime now '%s'\n",asctime(pTM));
- pTM=localtime(&aTimeBuffer.modtime);
- fprintf(stderr,"Modification now '%s'\n",asctime(pTM));
-
- fprintf(stderr,"File Times are (in UTC):\n");
- fprintf(stderr,"CreationTime now '%s'\n",ctime(&aFileStat.st_ctime));
- fprintf(stderr,"AccessTime now '%s'\n",ctime(&aTimeBuffer.actime));
- fprintf(stderr,"Modification now '%s'\n",ctime(&aTimeBuffer.modtime));
-#endif
-
- nRet=utime(pszFilePath,&aTimeBuffer);
- if ( nRet < 0 )
- {
- nRet=errno;
- return oslTranslateFileError(OSL_FET_ERROR, nRet);
- }
-
- return osl_File_E_None;
-}
-
-
-/*****************************************
- * osl_psz_removeFile
- ****************************************/
-
-static oslFileError osl_psz_removeFile( const sal_Char* pszPath )
-{
- int nRet=0;
- struct stat aStat;
-
- nRet = lstat(pszPath,&aStat);
- if ( nRet < 0 )
- {
- nRet=errno;
- return oslTranslateFileError(OSL_FET_ERROR, nRet);
- }
-
- if ( S_ISDIR(aStat.st_mode) )
- {
- return osl_File_E_ISDIR;
- }
-
- nRet = unlink(pszPath);
- if ( nRet < 0 )
- {
- nRet=errno;
- return oslTranslateFileError(OSL_FET_ERROR, nRet);
- }
-
- return osl_File_E_None;
-}
-
-/*****************************************
- * osl_psz_createDirectory
- ****************************************/
-
-static oslFileError osl_psz_createDirectory( const sal_Char* pszPath )
-{
- int nRet=0;
- int mode = S_IRWXU | S_IRWXG | S_IRWXO;
-
- nRet = mkdir(pszPath,mode);
-
- if ( nRet < 0 )
- {
- nRet=errno;
- return oslTranslateFileError(OSL_FET_ERROR, nRet);
- }
-
- return osl_File_E_None;
-}
-
-/*****************************************
- * osl_psz_removeDirectory
- ****************************************/
-
-static oslFileError osl_psz_removeDirectory( const sal_Char* pszPath )
-{
- int nRet=0;
-
- nRet = rmdir(pszPath);
-
- if ( nRet < 0 )
- {
- nRet=errno;
- return oslTranslateFileError(OSL_FET_ERROR, nRet);
- }
-
- return osl_File_E_None;
-}
-
-/*****************************************
- * oslDoMoveFile
- ****************************************/
-
-static oslFileError oslDoMoveFile( const sal_Char* pszPath, const sal_Char* pszDestPath)
-{
- oslFileError tErr=osl_File_E_invalidError;
-
- tErr = osl_psz_moveFile(pszPath,pszDestPath);
- if ( tErr == osl_File_E_None )
- {
- return tErr;
- }
-
- if ( tErr != osl_File_E_XDEV )
- {
- return tErr;
- }
-
- tErr=osl_psz_copyFile(pszPath,pszDestPath);
-
- if ( tErr != osl_File_E_None )
- {
- oslFileError tErrRemove;
- tErrRemove=osl_psz_removeFile(pszDestPath);
- return tErr;
- }
-
- tErr=osl_psz_removeFile(pszPath);
-
- return tErr;
-}
-
-/*****************************************
- * osl_psz_moveFile
- ****************************************/
-
-static oslFileError osl_psz_moveFile(const sal_Char* pszPath, const sal_Char* pszDestPath)
-{
-
- int nRet = 0;
-
- nRet = rename(pszPath,pszDestPath);
-
- if ( nRet < 0 )
- {
- nRet=errno;
- return oslTranslateFileError(OSL_FET_ERROR, nRet);
- }
-
- return osl_File_E_None;
-}
-
-/*****************************************
- * osl_psz_copyFile
- ****************************************/
-
-static oslFileError osl_psz_copyFile( const sal_Char* pszPath, const sal_Char* pszDestPath )
-{
- time_t nAcTime=0;
- time_t nModTime=0;
- uid_t nUID=0;
- gid_t nGID=0;
- int nRet=0;
- mode_t nMode=0;
- struct stat aFileStat;
- oslFileError tErr=osl_File_E_invalidError;
- size_t nSourceSize=0;
- int DestFileExists=1;
-
- /* mfe: does the source file really exists? */
- nRet = lstat(pszPath,&aFileStat);
-
- if ( nRet < 0 )
- {
- nRet=errno;
- return oslTranslateFileError(OSL_FET_ERROR, nRet);
- }
-
- /* mfe: we do only copy files here! */
- if ( S_ISDIR(aFileStat.st_mode) )
- {
- return osl_File_E_ISDIR;
- }
-
- nSourceSize=(size_t)aFileStat.st_size;
- nMode=aFileStat.st_mode;
- nAcTime=aFileStat.st_atime;
- nModTime=aFileStat.st_mtime;
- nUID=aFileStat.st_uid;
- nGID=aFileStat.st_gid;
-
- nRet = stat(pszDestPath,&aFileStat);
- if ( nRet < 0 )
- {
- nRet=errno;
-
- if ( nRet == ENOENT )
- {
- DestFileExists=0;
- }
-/* return oslTranslateFileError(nRet);*/
- }
-
- /* mfe: the destination file must not be a directory! */
- if ( nRet == 0 && S_ISDIR(aFileStat.st_mode) )
- {
- return osl_File_E_ISDIR;
- }
- else
- {
- /* mfe: file does not exists or is no dir */
- }
-
- tErr = oslDoCopy(pszPath,pszDestPath,nMode,nSourceSize,DestFileExists);
-
- if ( tErr != osl_File_E_None )
- {
- return tErr;
- }
-
- /*
- * mfe: ignore return code
- * since only the success of the copy is
- * important
- */
- oslChangeFileModes(pszDestPath,nMode,nAcTime,nModTime,nUID,nGID);
-
- return tErr;
-}
-
-
-/******************************************************************************
- *
- * Utility Functions
- *
- *****************************************************************************/
-
-/*****************************************
- * oslDoCopy
- ****************************************/
-
-#define TMP_DEST_FILE_EXTENSION ".osl-tmp"
-
-static oslFileError oslDoCopy(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, mode_t nMode, size_t nSourceSize, int DestFileExists)
-{
- int nRet=0;
- sal_Char pszTmpDestFile[PATH_MAX];
- size_t size_tmp_dest_buff = sizeof(pszTmpDestFile);
-
- /* Quick fix for #106048, the whole copy file function seems
- to be erroneous anyway and needs to be rewritten.
- Besides osl_copyFile is currently not used from OO/SO code.
- */
- memset(pszTmpDestFile, 0, size_tmp_dest_buff);
-
- if ( DestFileExists )
- {
- strncpy(pszTmpDestFile, pszDestFileName, size_tmp_dest_buff - 1);
-
- if ((strlen(pszTmpDestFile) + strlen(TMP_DEST_FILE_EXTENSION)) >= size_tmp_dest_buff)
- return osl_File_E_NAMETOOLONG;
-
- strncat(pszTmpDestFile, TMP_DEST_FILE_EXTENSION, strlen(TMP_DEST_FILE_EXTENSION));
-
- /* FIXME: what if pszTmpDestFile already exists? */
- /* with getcanonical??? */
- nRet=rename(pszDestFileName,pszTmpDestFile);
- }
-
- /* mfe: should be S_ISREG */
- if ( !S_ISLNK(nMode) )
- {
- /* copy SourceFile to DestFile */
- nRet = oslDoCopyFile(pszSourceFileName,pszDestFileName,nSourceSize, nMode);
- }
- /* mfe: OK redundant at the moment */
- else if ( S_ISLNK(nMode) )
- {
- nRet = oslDoCopyLink(pszSourceFileName,pszDestFileName);
- }
- else
- {
- /* mfe: what to do here? */
- nRet=ENOSYS;
- }
-
- if ( nRet > 0 && DestFileExists == 1 )
- {
- unlink(pszDestFileName);
- rename(pszTmpDestFile,pszDestFileName);
- }
-
- if ( nRet > 0 )
- {
- return oslTranslateFileError(OSL_FET_ERROR, nRet);
- }
-
- if ( DestFileExists == 1 )
- {
- unlink(pszTmpDestFile);
- }
-
- return osl_File_E_None;
-}
-
-/*****************************************
- * oslChangeFileModes
- ****************************************/
-
-static oslFileError oslChangeFileModes( const sal_Char* pszFileName, mode_t nMode, time_t nAcTime, time_t nModTime, uid_t nUID, gid_t nGID)
-{
- int nRet=0;
- struct utimbuf aTimeBuffer;
-
- nRet = chmod(pszFileName,nMode);
- if ( nRet < 0 )
- {
- nRet=errno;
- return oslTranslateFileError(OSL_FET_ERROR, nRet);
- }
-
- aTimeBuffer.actime=nAcTime;
- aTimeBuffer.modtime=nModTime;
- nRet=utime(pszFileName,&aTimeBuffer);
- if ( nRet < 0 )
- {
- nRet=errno;
- return oslTranslateFileError(OSL_FET_ERROR, nRet);
- }
-
- if ( nUID != getuid() )
- {
- nUID=getuid();
- }
-
- nRet=chown(pszFileName,nUID,nGID);
- if ( nRet < 0 )
- {
- nRet=errno;
-
- /* mfe: do not return an error here! */
- /* return oslTranslateFileError(nRet);*/
- }
-
- return osl_File_E_None;
-}
-
-/*****************************************
- * oslDoCopyLink
- ****************************************/
-
-static int oslDoCopyLink(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName)
-{
- int nRet=0;
-
- /* mfe: if dest file is symbolic link remove the link and place the file instead (hro says so) */
- /* mfe: if source is a link copy the link and not the file it points to (hro says so) */
- sal_Char pszLinkContent[PATH_MAX];
-
- pszLinkContent[0] = '\0';
-
- nRet = readlink(pszSourceFileName,pszLinkContent,PATH_MAX);
-
- if ( nRet < 0 )
- {
- nRet=errno;
- return nRet;
- }
- else
- pszLinkContent[ nRet ] = 0;
-
- nRet = symlink(pszLinkContent,pszDestFileName);
-
- if ( nRet < 0 )
- {
- nRet=errno;
- return nRet;
- }
-
- return 0;
-}
-
-/*****************************************
- * oslDoCopyFile
- ****************************************/
-
-static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, size_t nSourceSize, mode_t mode)
-{
- int SourceFileFD=0;
- int DestFileFD=0;
- int nRet=0;
- void* pSourceFile=0;
-
- SourceFileFD=open(pszSourceFileName,O_RDONLY);
- if ( SourceFileFD < 0 )
- {
- nRet=errno;
- return nRet;
- }
-
- DestFileFD=open(pszDestFileName, O_WRONLY | O_CREAT, mode);
-
- if ( DestFileFD < 0 )
- {
- nRet=errno;
- close(SourceFileFD);
- return nRet;
- }
-
- /* HACK: because memory mapping fails on various
- platforms if the size of the source file is 0 byte */
- if (0 == nSourceSize)
- {
- close(SourceFileFD);
- close(DestFileFD);
- return 0;
- }
-
- /* FIXME doCopy: fall back code for systems not having mmap */
- /* mmap file -- open dest file -- write once -- fsync it */
- pSourceFile=mmap(0,nSourceSize,PROT_READ,MAP_PRIVATE,SourceFileFD,0);
-
- if ( pSourceFile == MAP_FAILED )
- {
- /* it's important to set nRet before the hack
- otherwise errno may be changed by lstat */
- nRet = errno;
- close(SourceFileFD);
- close(DestFileFD);
-
- return nRet;
- }
-
- nRet = write(DestFileFD,pSourceFile,nSourceSize);
-
- /* #112584# if 'write' could not write the requested number of bytes
- we have to fail of course; because it's not exactly specified if 'write'
- sets errno if less than requested byte could be written we set nRet
- explicitly to ENOSPC */
- if ((nRet < 0) || (nRet != sal::static_int_cast< int >(nSourceSize)))
- {
- if (nRet < 0)
- nRet = errno;
- else
- nRet = ENOSPC;
-
- close(SourceFileFD);
- close(DestFileFD);
- munmap((char*)pSourceFile,nSourceSize);
- return nRet;
- }
-
- nRet = munmap((char*)pSourceFile,nSourceSize);
- if ( nRet < 0 )
- {
- nRet=errno;
- close(SourceFileFD);
- close(DestFileFD);
- return nRet;
- }
-
- close(SourceFileFD);
-
- // Removed call to 'fsync' again (#112584#) and instead
- // evaluate the return value of 'close' in order to detect
- // and report ENOSPC and other erronous conditions on close
- if (close(DestFileFD) == -1)
- return errno;
- else
- return 0;
-}
-
-/*****************************************
- * oslMakeUStrFromPsz
- ****************************************/
-
-static rtl_uString* oslMakeUStrFromPsz(const sal_Char* pszStr, rtl_uString** ustrValid)
-{
- rtl_string2UString(
- ustrValid,
- pszStr,
- rtl_str_getLength( pszStr ),
- osl_getThreadTextEncoding(),
- OUSTRING_TO_OSTRING_CVTFLAGS );
- OSL_ASSERT(*ustrValid != 0);
-
- return *ustrValid;
-}
-
-/*****************************************************************************
- * UnicodeToText
- * converting unicode to text manually saves us the penalty of a temporary
- * rtl_String object.
- ****************************************************************************/
-
-int UnicodeToText( char * buffer, size_t bufLen, const sal_Unicode * uniText, sal_Int32 uniTextLen )
-{
- rtl_UnicodeToTextConverter hConverter;
- sal_uInt32 nInfo;
- sal_Size nSrcChars, nDestBytes;
-
- /* stolen from rtl/string.c */
- hConverter = rtl_createUnicodeToTextConverter( osl_getThreadTextEncoding() );
-
- nDestBytes = rtl_convertUnicodeToText( hConverter, 0, uniText, uniTextLen,
- buffer, bufLen,
- OUSTRING_TO_OSTRING_CVTFLAGS | RTL_UNICODETOTEXT_FLAGS_FLUSH,
- &nInfo, &nSrcChars );
-
- rtl_destroyUnicodeToTextConverter( hConverter );
-
- if( nInfo & RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL )
- {
- errno = EOVERFLOW;
- return 0;
- }
-
- /* ensure trailing '\0' */
- buffer[nDestBytes] = '\0';
-
- return nDestBytes;
-}
-
-/*****************************************************************************
- TextToUnicode
-
- @param text
- The text to convert.
-
- @param text_buffer_size
- The number of characters.
-
- @param unic_text
- The unicode buffer.
-
- @param unic_text_buffer_size
- The size in characters of the unicode buffer.
-
- ****************************************************************************/
-
-int TextToUnicode(
- const char* text,
- size_t text_buffer_size,
- sal_Unicode* unic_text,
- sal_Int32 unic_text_buffer_size)
-{
- rtl_TextToUnicodeConverter hConverter;
- sal_uInt32 nInfo;
- sal_Size nSrcChars;
- sal_Size nDestBytes;
-
- /* stolen from rtl/string.c */
- hConverter = rtl_createTextToUnicodeConverter(osl_getThreadTextEncoding());
-
- nDestBytes = rtl_convertTextToUnicode(hConverter,
- 0,
- text, text_buffer_size,
- unic_text, unic_text_buffer_size,
- OSTRING_TO_OUSTRING_CVTFLAGS | RTL_TEXTTOUNICODE_FLAGS_FLUSH,
- &nInfo, &nSrcChars);
-
- rtl_destroyTextToUnicodeConverter(hConverter);
-
- if (nInfo & RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL)
- {
- errno = EOVERFLOW;
- return 0;
- }
-
- /* ensure trailing '\0' */
- unic_text[nDestBytes] = '\0';
-
- return nDestBytes;
-}
-
-/******************************************************************************
- *
- * GENERIC FLOPPY FUNCTIONS
- *
- *****************************************************************************/
-
-
-/*****************************************
- * osl_unmountVolumeDevice
- ****************************************/
-
-oslFileError osl_unmountVolumeDevice( oslVolumeDeviceHandle Handle )
-{
- oslFileError tErr = osl_File_E_NOSYS;
-
- tErr = osl_unmountFloppy(Handle);
-
- /* Perhaps current working directory is set to mount point */
-
- if ( tErr )
- {
- sal_Char *pszHomeDir = getenv("HOME");
-
- if ( pszHomeDir && strlen( pszHomeDir ) && 0 == chdir( pszHomeDir ) )
- {
- /* try again */
-
- tErr = osl_unmountFloppy(Handle);
-
- OSL_ENSURE( tErr, "osl_unmountvolumeDevice: CWD was set to volume mount point" );
- }
- }
-
- return tErr;
-}
-
-/*****************************************
- * osl_automountVolumeDevice
- ****************************************/
-
-oslFileError osl_automountVolumeDevice( oslVolumeDeviceHandle Handle )
-{
- oslFileError tErr = osl_File_E_NOSYS;
-
- tErr = osl_mountFloppy(Handle);
-
- return tErr;
-}
-
-/*****************************************
- * osl_getVolumeDeviceMountPath
- ****************************************/
-
-oslFileError osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uString **pstrPath )
-{
- oslVolumeDeviceHandleImpl* pItem = (oslVolumeDeviceHandleImpl*) Handle;
- sal_Char Buffer[PATH_MAX];
-
- Buffer[0] = '\0';
-
- if ( pItem == 0 || pstrPath == 0 )
- {
- return osl_File_E_INVAL;
- }
-
- if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
- {
- return osl_File_E_INVAL;
- }
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"Handle is:\n");
- osl_printFloppyHandle(pItem);
-#endif
-
- snprintf(Buffer, sizeof(Buffer), "file://%s", pItem->pszMountPoint);
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"Mount Point is: '%s'\n",Buffer);
-#endif
-
- oslMakeUStrFromPsz(Buffer, pstrPath);
-
- return osl_File_E_None;
-}
-
-/*****************************************
- * osl_acquireVolumeDeviceHandle
- ****************************************/
-
-oslFileError SAL_CALL osl_acquireVolumeDeviceHandle( oslVolumeDeviceHandle Handle )
-{
- oslVolumeDeviceHandleImpl* pItem =(oslVolumeDeviceHandleImpl*) Handle;
-
- if ( pItem == 0 )
- {
- return osl_File_E_INVAL;
- }
-
- if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
- {
- return osl_File_E_INVAL;
- }
-
- ++pItem->RefCount;
-
- return osl_File_E_None;
-}
-
-/*****************************************
- * osl_releaseVolumeDeviceHandle
- ****************************************/
-
-oslFileError osl_releaseVolumeDeviceHandle( oslVolumeDeviceHandle Handle )
-{
- oslVolumeDeviceHandleImpl* pItem =(oslVolumeDeviceHandleImpl*) Handle;
-
- if ( pItem == 0 )
- {
- return osl_File_E_INVAL;
- }
-
- if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
- {
- return osl_File_E_INVAL;
- }
-
- --pItem->RefCount;
-
- if ( pItem->RefCount == 0 )
- {
- rtl_freeMemory(pItem);
- }
-
- return osl_File_E_None;
-}
-
-#ifndef MACOSX
-
-/*****************************************
- * osl_newVolumeDeviceHandleImpl
- ****************************************/
-
-static oslVolumeDeviceHandleImpl* osl_newVolumeDeviceHandleImpl()
-{
- oslVolumeDeviceHandleImpl* pHandle;
- const size_t nSizeOfHandle = sizeof(oslVolumeDeviceHandleImpl);
-
- pHandle = (oslVolumeDeviceHandleImpl*) rtl_allocateMemory (nSizeOfHandle);
- if (pHandle != NULL)
- {
- pHandle->ident[0] = 'O';
- pHandle->ident[1] = 'V';
- pHandle->ident[2] = 'D';
- pHandle->ident[3] = 'H';
- pHandle->pszMountPoint[0] = '\0';
- pHandle->pszFilePath[0] = '\0';
- pHandle->pszDevice[0] = '\0';
- pHandle->RefCount = 1;
- }
- return pHandle;
-}
-
-/*****************************************
- * osl_freeVolumeDeviceHandleImpl
- ****************************************/
-
-static void osl_freeVolumeDeviceHandleImpl (oslVolumeDeviceHandleImpl* pHandle)
-{
- if (pHandle != NULL)
- rtl_freeMemory (pHandle);
-}
-#endif
-
-/******************************************************************************
- *
- * SOLARIS FLOPPY FUNCTIONS
- *
- *****************************************************************************/
-
-#if defined(SOLARIS)
-/* compare a given devicename with the typical device names on a Solaris box */
-static sal_Bool
-osl_isAFloppyDevice (const char* pDeviceName)
-{
- const char* pFloppyDevice [] = {
- "/dev/fd", "/dev/rfd",
- "/dev/diskette", "/dev/rdiskette",
- "/vol/dev/diskette", "/vol/dev/rdiskette"
- };
-
- int i;
- for (i = 0; i < (sizeof(pFloppyDevice)/sizeof(pFloppyDevice[0])); i++)
- {
- if (strncmp(pDeviceName, pFloppyDevice[i], strlen(pFloppyDevice[i])) == 0)
- return sal_True;
- }
- return sal_False;
-}
-
-/* compare two directories whether the first may be a parent of the second. this
- * does not realpath() resolving */
-static sal_Bool
-osl_isAParentDirectory (const char* pParentDir, const char* pSubDir)
-{
- return strncmp(pParentDir, pSubDir, strlen(pParentDir)) == 0;
-}
-
-/* the name of the routine is obviously silly. But anyway create a
- * oslVolumeDeviceHandle with correct mount point, device name and a resolved filepath
- * only if pszPath points to file or directory on a floppy */
-static oslVolumeDeviceHandle
-osl_isFloppyDrive(const sal_Char* pszPath)
-{
- FILE* pMountTab;
- struct mnttab aMountEnt;
- oslVolumeDeviceHandleImpl* pHandle;
-
- if ((pHandle = osl_newVolumeDeviceHandleImpl()) == NULL)
- {
- return NULL;
- }
- if (realpath(pszPath, pHandle->pszFilePath) == NULL)
- {
- osl_freeVolumeDeviceHandleImpl (pHandle);
- return NULL;
- }
- if ((pMountTab = fopen (MOUNTTAB, "r")) == NULL)
- {
- osl_freeVolumeDeviceHandleImpl (pHandle);
- return NULL;
- }
-
- while (getmntent(pMountTab, &aMountEnt) == 0)
- {
- const char *pMountPoint = aMountEnt.mnt_mountp;
- const char *pDevice = aMountEnt.mnt_special;
- if ( osl_isAParentDirectory (aMountEnt.mnt_mountp, pHandle->pszFilePath)
- && osl_isAFloppyDevice (aMountEnt.mnt_special))
- {
- /* skip the last item for it is the name of the disk */
- char * pc = strrchr( aMountEnt.mnt_special, '/' );
-
- if ( NULL != pc )
- {
- int len = pc - aMountEnt.mnt_special;
-
- strncpy( pHandle->pszDevice, aMountEnt.mnt_special, len );
- pHandle->pszDevice[len] = '\0';
- }
- else
- {
- /* #106048 use save str functions to avoid buffer overflows */
- memset(pHandle->pszDevice, 0, sizeof(pHandle->pszDevice));
- strncpy(pHandle->pszDevice, aMountEnt.mnt_special, sizeof(pHandle->pszDevice) - 1);
- }
-
- /* remember the mount point */
- memset(pHandle->pszMountPoint, 0, sizeof(pHandle->pszMountPoint));
- strncpy(pHandle->pszMountPoint, aMountEnt.mnt_mountp, sizeof(pHandle->pszMountPoint) - 1);
-
- fclose (pMountTab);
- return pHandle;
- }
- }
-
- fclose (pMountTab);
- osl_freeVolumeDeviceHandleImpl (pHandle);
- return NULL;
-}
-
-static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy)
-{
- FILE* pMountTab;
- struct mnttab aMountEnt;
- oslVolumeDeviceHandleImpl* pHandle = (oslVolumeDeviceHandleImpl*) hFloppy;
-
- int nRet=0;
- sal_Char pszCmd[512] = "";
-
- if ( pHandle == 0 )
- return osl_File_E_INVAL;
-
- /* FIXME: don't know what this is good for */
- if ( pHandle->ident[0] != 'O' || pHandle->ident[1] != 'V' || pHandle->ident[2] != 'D' || pHandle->ident[3] != 'H' )
- return osl_File_E_INVAL;
-
- snprintf(pszCmd, sizeof(pszCmd), "eject -q %s > /dev/null 2>&1", pHandle->pszDevice);
-
- nRet = system( pszCmd );
-
- switch ( WEXITSTATUS(nRet) )
- {
- case 0:
- {
- /* lookup the device in mount tab again */
- if ((pMountTab = fopen (MOUNTTAB, "r")) == NULL)
- return osl_File_E_BUSY;
-
- while (getmntent(pMountTab, &aMountEnt) == 0)
- {
- const char *pMountPoint = aMountEnt.mnt_mountp;
- const char *pDevice = aMountEnt.mnt_special;
- if ( 0 == strncmp( pHandle->pszDevice, aMountEnt.mnt_special, strlen(pHandle->pszDevice) ) )
- {
- memset(pHandle->pszMountPoint, 0, sizeof(pHandle->pszMountPoint));
- strncpy (pHandle->pszMountPoint, aMountEnt.mnt_mountp, sizeof(pHandle->pszMountPoint) - 1);
-
- fclose (pMountTab);
- return osl_File_E_None;
- }
- }
-
- fclose (pMountTab);
- return osl_File_E_BUSY;
- }
- //break; // break not necessary here, see return statements before
-
- case 1:
- return osl_File_E_BUSY;
-
- default:
- break;
- }
-
- return osl_File_E_BUSY;
-}
-
-static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy)
-{
-// FILE* pMountTab;
-// struct mnttab aMountEnt;
- oslVolumeDeviceHandleImpl* pHandle = (oslVolumeDeviceHandleImpl*) hFloppy;
-
- int nRet=0;
- sal_Char pszCmd[512] = "";
-
- if ( pHandle == 0 )
- return osl_File_E_INVAL;
-
- /* FIXME: don't know what this is good for */
- if ( pHandle->ident[0] != 'O' || pHandle->ident[1] != 'V' || pHandle->ident[2] != 'D' || pHandle->ident[3] != 'H' )
- return osl_File_E_INVAL;
-
- snprintf(pszCmd, sizeof(pszCmd), "eject %s > /dev/null 2>&1", pHandle->pszDevice);
-
- nRet = system( pszCmd );
-
- switch ( WEXITSTATUS(nRet) )
- {
- case 0:
- {
- FILE* pMountTab;
- struct mnttab aMountEnt;
-
- /* lookup if device is still in mount tab */
- if ((pMountTab = fopen (MOUNTTAB, "r")) == NULL)
- return osl_File_E_BUSY;
-
- while (getmntent(pMountTab, &aMountEnt) == 0)
- {
- const char *pMountPoint = aMountEnt.mnt_mountp;
- const char *pDevice = aMountEnt.mnt_special;
- if ( 0 == strncmp( pHandle->pszDevice, aMountEnt.mnt_special, strlen(pHandle->pszDevice) ) )
- {
- fclose (pMountTab);
- return osl_File_E_BUSY;
- }
- }
-
- fclose (pMountTab);
- pHandle->pszMountPoint[0] = 0;
- return osl_File_E_None;
- }
-
- //break; //break not necessary, see return statements before
-
- case 1:
- return osl_File_E_NODEV;
-
- case 4:
- pHandle->pszMountPoint[0] = 0;
- return osl_File_E_None;
-
- default:
- break;
- }
-
- return osl_File_E_BUSY;
-}
-
-#endif /* SOLARIS */
-
-/******************************************************************************
- *
- * LINUX FLOPPY FUNCTIONS
- *
- *****************************************************************************/
-
-#if defined(LINUX)
-static oslVolumeDeviceHandle
-osl_isFloppyDrive (const sal_Char* pszPath)
-{
- oslVolumeDeviceHandleImpl* pItem = osl_newVolumeDeviceHandleImpl();
- if (osl_getFloppyMountEntry(pszPath, pItem))
- return (oslVolumeDeviceHandle) pItem;
-
- osl_freeVolumeDeviceHandleImpl (pItem);
- return 0;
-}
-#endif /* LINUX */
-
-#if defined(LINUX)
-static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy)
-{
- sal_Bool bRet = sal_False;
- oslVolumeDeviceHandleImpl* pItem=0;
- int nRet;
- sal_Char pszCmd[PATH_MAX];
- const sal_Char* pszMountProg = "mount";
- sal_Char* pszSuDo = 0;
- sal_Char* pszTmp = 0;
-
- pszCmd[0] = '\0';
-
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"In osl_mountFloppy\n");
-#endif
-
- pItem = (oslVolumeDeviceHandleImpl*) hFloppy;
-
- if ( pItem == 0 )
- {
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_mountFloppy [pItem == 0]\n");
-#endif
-
- return osl_File_E_INVAL;
- }
-
- if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
- {
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_mountFloppy [invalid handle]\n");
-#endif
- return osl_File_E_INVAL;
- }
-
- bRet = osl_isFloppyMounted(pItem);
- if ( bRet == sal_True )
- {
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"detected mounted floppy at '%s'\n",pItem->pszMountPoint);
-#endif
- return osl_File_E_BUSY;
- }
-
- /* mfe: we can't use the mount(2) system call!!! */
- /* even if we are root */
- /* since mtab is not updated!!! */
- /* but we need it to be updated */
- /* some "magic" must be done */
-
-/* nRet = mount(pItem->pszDevice,pItem->pszMountPoint,0,0,0); */
-/* if ( nRet != 0 ) */
-/* { */
-/* nRet=errno; */
-/* #ifdef DEBUG_OSL_FILE */
-/* perror("mount"); */
-/* #endif */
-/* } */
-
- pszTmp = getenv("SAL_MOUNT_MOUNTPROG");
- if ( pszTmp != 0 )
- {
- pszMountProg=pszTmp;
- }
-
- pszTmp=getenv("SAL_MOUNT_SU_DO");
- if ( pszTmp != 0 )
- {
- pszSuDo=pszTmp;
- }
-
- if ( pszSuDo != 0 )
- {
- snprintf(pszCmd, sizeof(pszCmd), "%s %s %s %s",pszSuDo,pszMountProg,pItem->pszDevice,pItem->pszMountPoint);
- }
- else
- {
- snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszMountProg,pItem->pszMountPoint);
- }
-
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"executing '%s'\n",pszCmd);
-#endif
-
- nRet = system(pszCmd);
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"call returned '%i'\n",nRet);
- fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet));
-#endif
-
-
- switch ( WEXITSTATUS(nRet) )
- {
- case 0:
- nRet=0;
- break;
-
- case 2:
- nRet=EPERM;
- break;
-
- case 4:
- nRet=ENOENT;
- break;
-
- case 8:
- nRet=EINTR;
- break;
-
- case 16:
- nRet=EPERM;
- break;
-
- case 32:
- nRet=EBUSY;
- break;
-
- case 64:
- nRet=EAGAIN;
- break;
-
- default:
- nRet=EBUSY;
- break;
- }
-
- return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet));
-}
-#endif /* LINUX */
-
-
-#if defined(LINUX)
-static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy)
-{
- oslVolumeDeviceHandleImpl* pItem=0;
- int nRet=0;
- sal_Char pszCmd[PATH_MAX];
- sal_Char* pszTmp = 0;
- sal_Char* pszSuDo = 0;
- const sal_Char* pszUmountProg = "umount";
-
- pszCmd[0] = '\0';
-
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"In osl_unmountFloppy\n");
-#endif
-
- pItem = (oslVolumeDeviceHandleImpl*) hFloppy;
-
- if ( pItem == 0 )
- {
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_unmountFloppy [pItem==0]\n");
-#endif
- return osl_File_E_INVAL;
- }
-
- if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
- {
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_unmountFloppy [invalid handle]\n");
-#endif
- return osl_File_E_INVAL;
- }
-
- /* mfe: we can't use the umount(2) system call!!! */
- /* even if we are root */
- /* since mtab is not updated!!! */
- /* but we need it to be updated */
- /* some "magic" must be done */
-
-/* nRet=umount(pItem->pszDevice); */
-/* if ( nRet != 0 ) */
-/* { */
-/* nRet = errno; */
-
-/* #ifdef DEBUG_OSL_FILE */
-/* perror("mount"); */
-/* #endif */
-/* } */
-
-
- pszTmp = getenv("SAL_MOUNT_UMOUNTPROG");
- if ( pszTmp != 0 )
- {
- pszUmountProg=pszTmp;
- }
-
- pszTmp = getenv("SAL_MOUNT_SU_DO");
- if ( pszTmp != 0 )
- {
- pszSuDo=pszTmp;
- }
-
- if ( pszSuDo != 0 )
- {
- snprintf(pszCmd, sizeof(pszCmd), "%s %s %s",pszSuDo,pszUmountProg,pItem->pszMountPoint);
- }
- else
- {
- snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszUmountProg,pItem->pszMountPoint);
- }
-
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"executing '%s'\n",pszCmd);
-#endif
-
- nRet = system(pszCmd);
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"call returned '%i'\n",nRet);
- fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet));
-#endif
-
- switch ( WEXITSTATUS(nRet) )
- {
- case 0:
- nRet=0;
- break;
-
- default:
- nRet=EBUSY;
- break;
- }
-
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_unmountFloppy [ok]\n");
-#endif
-
- return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet));
-
-/* return osl_File_E_None;*/
-}
-
-#endif /* LINUX */
-
-#if defined(LINUX)
-static sal_Bool
-osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem)
-{
- struct mntent* pMountEnt;
- FILE* pMountTab;
-
- pMountTab = setmntent (MOUNTTAB, "r");
- if (pMountTab == 0)
- return sal_False;
-
- while ((pMountEnt = getmntent(pMountTab)) != 0)
- {
- if ( strncmp(pMountEnt->mnt_dir, pszPath, strlen(pMountEnt->mnt_dir)) == 0
- && strncmp(pMountEnt->mnt_fsname, "/dev/fd", strlen("/dev/fd")) == 0)
- {
- memset(pItem->pszMountPoint, 0, sizeof(pItem->pszMountPoint));
- strncpy(pItem->pszMountPoint, pMountEnt->mnt_dir, sizeof(pItem->pszMountPoint) - 1);
-
- memset(pItem->pszFilePath, 0, sizeof(pItem->pszFilePath));
- strncpy(pItem->pszFilePath, pMountEnt->mnt_dir, sizeof(pItem->pszFilePath) - 1);
-
- memset(pItem->pszDevice, 0, sizeof(pItem->pszDevice));
- strncpy(pItem->pszDevice, pMountEnt->mnt_fsname, sizeof(pItem->pszDevice) - 1);
-
- endmntent (pMountTab);
- return sal_True;
- }
- }
-
- endmntent (pMountTab);
- return sal_False;
-}
-#endif /* LINUX */
-
-#if defined(LINUX)
-static sal_Bool
-osl_isFloppyMounted (oslVolumeDeviceHandleImpl* pDevice)
-{
- oslVolumeDeviceHandleImpl aItem;
-
- if ( osl_getFloppyMountEntry (pDevice->pszMountPoint, &aItem)
- && strcmp (aItem.pszMountPoint, pDevice->pszMountPoint) == 0
- && strcmp (aItem.pszDevice, pDevice->pszDevice) == 0)
- {
- return sal_True;
- }
- return sal_False;
-}
-#endif /* LINUX */
-
-/******************************************************************************
- *
- * IRIX FLOPPY FUNCTIONS
- *
- *****************************************************************************/
-
-#if defined(IRIX)
-static oslVolumeDeviceHandle osl_isFloppyDrive(const sal_Char* pszPath)
-{
- oslVolumeDeviceHandleImpl* pItem = osl_newVolumeDeviceHandleImpl ();
- sal_Bool bRet = sal_False;
-
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"In osl_isFloppyDrive\n");
-#endif
-
- bRet=osl_getFloppyMountEntry(pszPath,pItem);
-
- if ( bRet == sal_False )
- {
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_isFloppyDrive [not a floppy]\n");
-#endif
- rtl_freeMemory(pItem);
- return 0;
- }
-
-
-#ifdef DEBUG_OSL_FILE
- osl_printFloppyHandle(pItem);
-#endif
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_isFloppyDrive [ok]\n");
-#endif
-
- return (oslVolumeDeviceHandle) pItem;
-}
-
-
-static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy)
-{
- sal_Bool bRet = sal_False;
- oslVolumeDeviceHandleImpl* pItem=0;
- int nRet;
- sal_Char pszCmd[PATH_MAX];
- sal_Char* pszMountProg = "mount";
- sal_Char* pszSuDo = 0;
- sal_Char* pszTmp = 0;
-
- pszCmd[0] = '\0';
-
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"In osl_mountFloppy\n");
-#endif
-
- pItem = (oslVolumeDeviceHandleImpl*) hFloppy;
-
- if ( pItem == 0 )
- {
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_mountFloppy [pItem == 0]\n");
-#endif
-
- return osl_File_E_INVAL;
- }
-
- if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
- {
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_mountFloppy [invalid handle]\n");
-#endif
- return osl_File_E_INVAL;
- }
-
- bRet = osl_isFloppyMounted(pItem);
- if ( bRet == sal_True )
- {
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"detected mounted floppy at '%s'\n",pItem->pszMountPoint);
-#endif
- return osl_File_E_BUSY;
- }
-
- /* mfe: we can't use the mount(2) system call!!! */
- /* even if we are root */
- /* since mtab is not updated!!! */
- /* but we need it to be updated */
- /* some "magic" must be done */
-
-/* nRet = mount(pItem->pszDevice,pItem->pszMountPoint,0,0,0); */
-/* if ( nRet != 0 ) */
-/* { */
-/* nRet=errno; */
-/* #ifdef DEBUG_OSL_FILE */
-/* perror("mount"); */
-/* #endif */
-/* } */
-
- pszTmp = getenv("SAL_MOUNT_MOUNTPROG");
- if ( pszTmp != 0 )
- {
- pszMountProg=pszTmp;
- }
-
- pszTmp=getenv("SAL_MOUNT_SU_DO");
- if ( pszTmp != 0 )
- {
- pszSuDo=pszTmp;
- }
-
- if ( pszSuDo != 0 )
- {
- snprintf(pszCmd, sizeof(pszCmd), "%s %s %s %s",pszSuDo,pszMountProg,pItem->pszDevice,pItem->pszMountPoint);
- }
- else
- {
- snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszMountProg,pItem->pszMountPoint);
- }
-
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"executing '%s'\n",pszCmd);
-#endif
-
- nRet = system(pszCmd);
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"call returned '%i'\n",nRet);
- fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet));
-#endif
-
-
- switch ( WEXITSTATUS(nRet) )
- {
- case 0:
- nRet=0;
- break;
-
- case 2:
- nRet=EPERM;
- break;
-
- case 4:
- nRet=ENOENT;
- break;
-
- case 8:
- nRet=EINTR;
- break;
-
- case 16:
- nRet=EPERM;
- break;
-
- case 32:
- nRet=EBUSY;
- break;
-
- case 64:
- nRet=EAGAIN;
- break;
-
- default:
- nRet=EBUSY;
- break;
- }
-
- return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet));
-}
-
-static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy)
-{
- oslVolumeDeviceHandleImpl* pItem=0;
- int nRet=0;
- sal_Char pszCmd[PATH_MAX];
- sal_Char* pszTmp = 0;
- sal_Char* pszSuDo = 0;
- sal_Char* pszUmountProg = "umount";
-
- pszCmd[0] = '\0';
-
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"In osl_unmountFloppy\n");
-#endif
-
- pItem = (oslVolumeDeviceHandleImpl*) hFloppy;
-
- if ( pItem == 0 )
- {
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_unmountFloppy [pItem==0]\n");
-#endif
- return osl_File_E_INVAL;
- }
-
- if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
- {
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_unmountFloppy [invalid handle]\n");
-#endif
- return osl_File_E_INVAL;
- }
-
- /* mfe: we can't use the umount(2) system call!!! */
- /* even if we are root */
- /* since mtab is not updated!!! */
- /* but we need it to be updated */
- /* some "magic" must be done */
-
-/* nRet=umount(pItem->pszDevice); */
-/* if ( nRet != 0 ) */
-/* { */
-/* nRet = errno; */
-
-/* #ifdef DEBUG_OSL_FILE */
-/* perror("mount"); */
-/* #endif */
-/* } */
-
-
- pszTmp = getenv("SAL_MOUNT_UMOUNTPROG");
- if ( pszTmp != 0 )
- {
- pszUmountProg=pszTmp;
- }
-
- pszTmp = getenv("SAL_MOUNT_SU_DO");
- if ( pszTmp != 0 )
- {
- pszSuDo=pszTmp;
- }
-
- if ( pszSuDo != 0 )
- {
- snprintf(pszCmd, sizeof(pszCmd), "%s %s %s",pszSuDo,pszUmountProg,pItem->pszMountPoint);
- }
- else
- {
- snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszUmountProg,pItem->pszMountPoint);
- }
-
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"executing '%s'\n",pszCmd);
-#endif
-
- nRet = system(pszCmd);
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"call returned '%i'\n",nRet);
- fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet));
-#endif
-
- switch ( WEXITSTATUS(nRet) )
- {
- case 0:
- nRet=0;
- break;
-
- default:
- nRet=EBUSY;
- break;
- }
-
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_unmountFloppy [ok]\n");
-#endif
-
- return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet));
-
-/* return osl_File_E_None;*/
-}
-
-static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem)
-{
- struct mntent* pMountEnt=0;
- sal_Char buffer[PATH_MAX];
- FILE* mntfile=0;
- int nRet=0;
-
- buffer[0] = '\0';
-
- mntfile = setmntent(MOUNTTAB,"r");
-
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"In osl_getFloppyMountEntry\n");
-#endif
-
- memset(buffer, 0, sizeof(buffer));
- strncpy(buffer, pszPath, sizeof(buffer) - 1);
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"Checking mount of %s\n",buffer);
-#endif
-
-
- if ( mntfile == 0 )
- {
- nRet=errno;
-#ifdef DEBUG_OSL_FILE
- perror("mounttab");
-#endif
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_getFloppyMountEntry [mntfile]\n");
-#endif
- return sal_False;
- }
-
- pMountEnt=getmntent(mntfile);
- while ( pMountEnt != 0 )
- {
-#ifdef DEBUG_OSL_FILE
-/* fprintf(stderr,"mnt_fsname : %s\n",pMountEnt->mnt_fsname); */
-/* fprintf(stderr,"mnt_dir : %s\n",pMountEnt->mnt_dir); */
-/* fprintf(stderr,"mnt_type : %s\n",pMountEnt->mnt_type);*/
-#endif
- if ( strcmp(pMountEnt->mnt_dir,buffer) == 0 &&
- strncmp(pMountEnt->mnt_fsname,"/dev/fd",strlen("/dev/fd")) == 0 )
- {
-
- memset(pItem->pszMountPoint, 0, sizeof(pItem->pszMountPoint));
- strncpy(pItem->pszMountPoint, pMountEnt->mnt_dir, sizeof(pItem->pszMountPoint) - 1);
-
- memset(pItem->pszFilePath, 0, sizeof(pItem->pszFilePath));
- strncpy(pItem->pszFilePath, pMountEnt->mnt_dir, sizeof(pItem->pszFilePath) - 1);
-
- memset(pItem->pszDevice, 0, sizeof(pItem->pszDevice));
- strncpy(pItem->pszDevice, pMountEnt->mnt_fsname, sizeof(pItem->pszDevice) - 1);
-
- fclose(mntfile);
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"Mount Point found '%s'\n",pItem->pszMountPoint);
-#endif
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_getFloppyMountEntry [found]\n");
-#endif
- return sal_True;
- }
-#ifdef DEBUG_OSL_FILE
-/* fprintf(stderr,"=================\n");*/
-#endif
- pMountEnt=getmntent(mntfile);
- }
-
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_getFloppyMountEntry [not found]\n");
-#endif
-
- fclose(mntfile);
- return sal_False;
-}
-
-static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice)
-{
- sal_Char buffer[PATH_MAX];
- oslVolumeDeviceHandleImpl* pItem=0;
- sal_Bool bRet=0;
-
- buffer[0] = '\0';
-
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"In osl_isFloppyMounted\n");
-#endif
-
- pItem = osl_newVolumeDeviceHandleImpl ();
- if ( pItem == 0 )
- return osl_File_E_NOMEM;
-
- memset(buffer, 0, sizeof(buffer));
- strncpy(buffer, pDevice->pszMountPoint, sizeof(buffer) - 1);
-
-#ifdef DEBUG_OSL_FILE
- fprintf(stderr,"Checking mount of %s\n",buffer);
-#endif
-
- bRet = osl_getFloppyMountEntry(buffer,pItem);
-
- if ( bRet == sal_False )
- {
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_isFloppyMounted [not mounted]\n");
-#endif
- return sal_False;
- }
-
- if (strcmp(pItem->pszMountPoint, pDevice->pszMountPoint) == 0 &&
- strcmp(pItem->pszDevice,pDevice->pszDevice) == 0)
- {
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_isFloppyMounted [is mounted]\n");
-#endif
- rtl_freeMemory(pItem);
- return sal_True;
- }
-
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Out osl_isFloppyMounted [may be EBUSY]\n");
-#endif
-
- rtl_freeMemory(pItem);
- return sal_False;
-}
-#endif /* IRIX */
-
-
-/* NetBSD floppy functions have to be added here. Until we have done that,
- * we use the MACOSX definitions for nonexistent floppy.
- * */
-
-/******************************************************************************
- *
- * MAC OS X FLOPPY FUNCTIONS
- *
- *****************************************************************************/
-
-#if (defined(MACOSX) || defined(NETBSD) || defined(FREEBSD))
-static oslVolumeDeviceHandle osl_isFloppyDrive(const sal_Char* pszPath)
-{
- return NULL;
-}
-#endif /* MACOSX */
-
-#if ( defined(MACOSX) || defined(NETBSD) || defined(FREEBSD))
-static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy)
-{
- return osl_File_E_BUSY;
-}
-#endif /* MACOSX */
-
-#if ( defined(MACOSX) || defined(NETBSD) || defined(FREEBSD))
-static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy)
-{
- return osl_File_E_BUSY;
-}
-#endif /* MACOSX */
-
-#if ( defined(NETBSD) || defined(FREEBSD) )
-static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem)
-{
- return sal_False;
-}
-#endif /* NETBSD || FREEBSD */
-
-#if ( defined(NETBSD) || defined(FREEBSD) )
-static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice)
-{
- return sal_False;
-}
-#endif /* NETBSD || FREEBSD */
-
-
-#ifdef DEBUG_OSL_FILE
-static void osl_printFloppyHandle(oslVolumeDeviceHandleImpl* pItem)
-{
- if (pItem == 0 )
- {
- fprintf(stderr,"NULL Handle\n");
- return;
- }
- if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
- {
-#ifdef TRACE_OSL_FILE
- fprintf(stderr,"Invalid Handle]\n");
-#endif
- return;
- }
-
-
- fprintf(stderr,"MountPoint : '%s'\n",pItem->pszMountPoint);
- fprintf(stderr,"FilePath : '%s'\n",pItem->pszFilePath);
- fprintf(stderr,"Device : '%s'\n",pItem->pszDevice);
-
- return;
-}
-#endif
-
diff --git a/sal/osl/unx/file_impl.hxx b/sal/osl/unx/file_impl.hxx
index ae9d56ca85f3..db85b00cbfef 100644
--- a/sal/osl/unx/file_impl.hxx
+++ b/sal/osl/unx/file_impl.hxx
@@ -28,21 +28,30 @@
*
************************************************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-typedef struct
+#ifndef INCLUDED_FILE_IMPL_HXX
+#define INCLUDED_FILE_IMPL_HXX
+
+#include "osl/file.h"
+#include <stddef.h>
+
+struct DirectoryItem_Impl
{
- rtl_uString* ustrFilePath; /* holds native file name */
- unsigned char DType;
- bool bHasType;
- sal_uInt32 RefCount;
-} oslDirectoryItemImpl;
-
- oslDirectoryItemImpl* oslDirectoryItemImpl_CreateNew( rtl_uString* _ustrFilePath, bool _bHasDType, unsigned char _DType=0 );
- void oslDirectoryItemImpl_Destroy( oslDirectoryItemImpl* pItem );
- void oslDirectoryItemImpl_acquire( oslDirectoryItemImpl* pItem );
- void oslDirectoryItemImpl_release( oslDirectoryItemImpl* pItem );
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
+ sal_Int32 m_RefCount;
+
+ rtl_uString * m_ustrFilePath; /* holds native file name */
+ unsigned char m_DType;
+
+ explicit DirectoryItem_Impl(
+ rtl_uString * ustrFilePath, unsigned char DType = 0);
+ ~DirectoryItem_Impl();
+
+ static void * operator new(size_t n);
+ static void operator delete (void * p, size_t);
+
+ void acquire(); /* @see osl_acquireDirectoryItem() */
+ void release(); /* @see osl_releaseDirectoryItem() */
+
+ oslFileType getFileType() const;
+};
+
+#endif /* INCLUDED_FILE_IMPL_HXX */
diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
new file mode 100644
index 000000000000..3f3cf02fb010
--- /dev/null
+++ b/sal/osl/unx/file_misc.cxx
@@ -0,0 +1,1084 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "osl/file.hxx"
+
+#include "osl/diagnose.h"
+#include "osl/thread.h"
+#include "rtl/alloc.h"
+
+#include "system.h"
+#include "file_impl.hxx"
+#include "file_error_transl.h"
+#include "file_path_helper.hxx"
+#include "file_url.h"
+#include "uunxapi.hxx"
+
+#include <sys/types.h>
+#include <errno.h>
+#include <dirent.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+
+/************************************************************************
+ * ToDo
+ *
+ * - Fix: check for corresponding struct sizes in exported functions
+ * - check size/use of oslDirectory
+ * - check size/use of oslDirectoryItem
+ ***********************************************************************/
+/******************************************************************************
+ *
+ * Data Type Definition
+ *
+ ******************************************************************************/
+
+typedef struct
+{
+ rtl_uString* ustrPath; /* holds native directory path */
+ DIR* pDirStruct;
+} oslDirectoryImpl;
+
+#if 0
+/* FIXME: reintroducing this may save some extra bytes per Item */
+typedef struct
+{
+ rtl_uString* ustrFileName; /* holds native file name */
+ rtl_uString* ustrDirPath; /* holds native dir path */
+ sal_uInt32 RefCount;
+} oslDirectoryItemImpl;
+#endif
+
+DirectoryItem_Impl::DirectoryItem_Impl(
+ rtl_uString * ustrFilePath, unsigned char DType)
+ : m_RefCount (1),
+ m_ustrFilePath (ustrFilePath),
+ m_DType (DType)
+{
+ if (m_ustrFilePath != 0)
+ rtl_uString_acquire(m_ustrFilePath);
+}
+DirectoryItem_Impl::~DirectoryItem_Impl()
+{
+ if (m_ustrFilePath != 0)
+ rtl_uString_release(m_ustrFilePath);
+}
+
+void * DirectoryItem_Impl::operator new(size_t n)
+{
+ return rtl_allocateMemory(n);
+}
+void DirectoryItem_Impl::operator delete(void * p, size_t)
+{
+ rtl_freeMemory(p);
+}
+
+void DirectoryItem_Impl::acquire()
+{
+ ++m_RefCount;
+}
+void DirectoryItem_Impl::release()
+{
+ if (0 == --m_RefCount)
+ delete this;
+}
+
+oslFileType DirectoryItem_Impl::getFileType() const
+{
+ switch (m_DType)
+ {
+#ifdef _DIRENT_HAVE_D_TYPE
+ case DT_LNK:
+ return osl_File_Type_Link;
+ case DT_DIR:
+ return osl_File_Type_Directory;
+ case DT_REG:
+ return osl_File_Type_Regular;
+ case DT_FIFO:
+ return osl_File_Type_Fifo;
+ case DT_SOCK:
+ return osl_File_Type_Socket;
+ case DT_CHR:
+ case DT_BLK:
+ return osl_File_Type_Special;
+#endif /* _DIRENT_HAVE_D_TYPE */
+ default:
+ break;
+ }
+ return osl_File_Type_Unknown;
+}
+
+/******************************************************************************
+ *
+ * C-String Function Declarations
+ *
+ *****************************************************************************/
+
+static oslFileError osl_psz_createDirectory(const sal_Char* pszPath);
+static oslFileError osl_psz_removeDirectory(const sal_Char* pszPath);
+
+/*******************************************************************
+ * osl_openDirectory
+ ******************************************************************/
+
+oslFileError SAL_CALL osl_openDirectory(rtl_uString* ustrDirectoryURL, oslDirectory* pDirectory)
+{
+ rtl_uString* ustrSystemPath = NULL;
+ oslFileError eRet;
+
+ char path[PATH_MAX];
+
+ if ((0 == ustrDirectoryURL) || (0 == ustrDirectoryURL->length) || (0 == pDirectory))
+ return osl_File_E_INVAL;
+
+ /* convert file URL to system path */
+ eRet = osl_getSystemPathFromFileURL_Ex(ustrDirectoryURL, &ustrSystemPath, sal_False);
+
+ if( osl_File_E_None != eRet )
+ return eRet;
+
+ osl_systemPathRemoveSeparator(ustrSystemPath);
+
+ /* convert unicode path to text */
+ if ( UnicodeToText( path, PATH_MAX, ustrSystemPath->buffer, ustrSystemPath->length )
+#ifdef MACOSX
+ && macxp_resolveAlias( path, PATH_MAX ) == 0
+#endif /* MACOSX */
+ )
+ {
+ /* open directory */
+ DIR *pdir = opendir( path );
+
+ if( pdir )
+ {
+ /* create and initialize impl structure */
+ oslDirectoryImpl* pDirImpl = (oslDirectoryImpl*) rtl_allocateMemory( sizeof(oslDirectoryImpl) );
+
+ if( pDirImpl )
+ {
+ pDirImpl->pDirStruct = pdir;
+ pDirImpl->ustrPath = ustrSystemPath;
+
+ *pDirectory = (oslDirectory) pDirImpl;
+ return osl_File_E_None;
+ }
+ else
+ {
+ errno = ENOMEM;
+ closedir( pdir );
+ }
+ }
+ else
+ {
+#ifdef DEBUG_OSL_FILE
+ perror ("osl_openDirectory"); fprintf (stderr, path);
+#endif
+ }
+ }
+
+ rtl_uString_release( ustrSystemPath );
+
+ return oslTranslateFileError(OSL_FET_ERROR, errno);
+}
+
+/****************************************************************************/
+/* osl_closeDirectory */
+/****************************************************************************/
+
+oslFileError SAL_CALL osl_closeDirectory( oslDirectory Directory )
+{
+ oslDirectoryImpl* pDirImpl = (oslDirectoryImpl*) Directory;
+ oslFileError err = osl_File_E_None;
+
+ OSL_ASSERT( Directory );
+
+ if( NULL == pDirImpl )
+ return osl_File_E_INVAL;
+
+ /* close directory */
+ if( closedir( pDirImpl->pDirStruct ) )
+ {
+ err = oslTranslateFileError(OSL_FET_ERROR, errno);
+ }
+
+ /* cleanup members */
+ rtl_uString_release( pDirImpl->ustrPath );
+
+ rtl_freeMemory( pDirImpl );
+
+ return err;
+}
+
+/**********************************************
+ * osl_readdir_impl_
+ *
+ * readdir wrapper, filters out "." and ".."
+ * on request
+ *********************************************/
+
+static struct dirent* osl_readdir_impl_(DIR* pdir, sal_Bool bFilterLocalAndParentDir)
+{
+ struct dirent* pdirent;
+
+ while ((pdirent = readdir(pdir)) != NULL)
+ {
+ if (bFilterLocalAndParentDir &&
+ ((0 == strcmp(pdirent->d_name, ".")) || (0 == strcmp(pdirent->d_name, ".."))))
+ continue;
+ else
+ break;
+ }
+
+ return pdirent;
+}
+
+/****************************************************************************
+ * osl_getNextDirectoryItem
+ ***************************************************************************/
+
+oslFileError SAL_CALL osl_getNextDirectoryItem(oslDirectory Directory, oslDirectoryItem* pItem, sal_uInt32 /*uHint*/)
+{
+ oslDirectoryImpl* pDirImpl = (oslDirectoryImpl*)Directory;
+ rtl_uString* ustrFileName = NULL;
+ rtl_uString* ustrFilePath = NULL;
+ struct dirent* pEntry;
+
+ OSL_ASSERT(Directory);
+ OSL_ASSERT(pItem);
+
+ if ((NULL == Directory) || (NULL == pItem))
+ return osl_File_E_INVAL;
+
+ pEntry = osl_readdir_impl_(pDirImpl->pDirStruct, sal_True);
+
+ if (NULL == pEntry)
+ return osl_File_E_NOENT;
+
+
+#if defined(MACOSX)
+
+ // convert decomposed filename to precomposed unicode
+ char composed_name[BUFSIZ];
+ CFMutableStringRef strRef = CFStringCreateMutable (NULL, 0 );
+ CFStringAppendCString( strRef, pEntry->d_name, kCFStringEncodingUTF8 ); //UTF8 is default on Mac OSX
+ CFStringNormalize( strRef, kCFStringNormalizationFormC );
+ CFStringGetCString( strRef, composed_name, BUFSIZ, kCFStringEncodingUTF8 );
+ CFRelease( strRef );
+ rtl_string2UString( &ustrFileName, composed_name, strlen( composed_name),
+ osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
+
+#else // not MACOSX
+ /* convert file name to unicode */
+ rtl_string2UString( &ustrFileName, pEntry->d_name, strlen( pEntry->d_name ),
+ osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
+ OSL_ASSERT(ustrFileName != 0);
+
+#endif
+
+ osl_systemPathMakeAbsolutePath(pDirImpl->ustrPath, ustrFileName, &ustrFilePath);
+ rtl_uString_release( ustrFileName );
+
+ DirectoryItem_Impl * pImpl = static_cast< DirectoryItem_Impl* >(*pItem);
+ if (0 != pImpl)
+ {
+ pImpl->release(), pImpl = 0;
+ }
+#ifdef _DIRENT_HAVE_D_TYPE
+ pImpl = new DirectoryItem_Impl(ustrFilePath, pEntry->d_type);
+#else
+ pImpl = new DirectoryItem_Impl(ustrFilePath);
+#endif /* _DIRENT_HAVE_D_TYPE */
+ *pItem = pImpl;
+ rtl_uString_release( ustrFilePath );
+
+ return osl_File_E_None;
+}
+
+/****************************************************************************/
+/* osl_getDirectoryItem */
+/****************************************************************************/
+
+oslFileError SAL_CALL osl_getDirectoryItem( rtl_uString* ustrFileURL, oslDirectoryItem* pItem )
+{
+ rtl_uString* ustrSystemPath = NULL;
+ oslFileError osl_error = osl_File_E_INVAL;
+
+ OSL_ASSERT(ustrFileURL);
+ OSL_ASSERT(pItem);
+
+ if (0 == ustrFileURL->length || NULL == pItem)
+ return osl_File_E_INVAL;
+
+ osl_error = osl_getSystemPathFromFileURL_Ex(ustrFileURL, &ustrSystemPath, sal_False);
+ if (osl_File_E_None != osl_error)
+ return osl_error;
+
+ osl_systemPathRemoveSeparator(ustrSystemPath);
+
+ if (-1 == access_u(ustrSystemPath, F_OK))
+ {
+ osl_error = oslTranslateFileError(OSL_FET_ERROR, errno);
+ }
+ else
+ {
+ *pItem = new DirectoryItem_Impl(ustrSystemPath);
+ }
+ rtl_uString_release(ustrSystemPath);
+
+ return osl_error;
+}
+
+
+/****************************************************************************/
+/* osl_acquireDirectoryItem */
+/****************************************************************************/
+
+oslFileError SAL_CALL osl_acquireDirectoryItem( oslDirectoryItem Item )
+{
+ DirectoryItem_Impl * pImpl = static_cast< DirectoryItem_Impl* >(Item);
+ if (0 == pImpl)
+ return osl_File_E_INVAL;
+
+ pImpl->acquire();
+ return osl_File_E_None;
+}
+
+/****************************************************************************/
+/* osl_releaseDirectoryItem */
+/****************************************************************************/
+
+oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item )
+{
+ DirectoryItem_Impl * pImpl = static_cast< DirectoryItem_Impl* >(Item);
+ if (0 == pImpl)
+ return osl_File_E_INVAL;
+
+ pImpl->release();
+ return osl_File_E_None;
+}
+
+/****************************************************************************/
+/* osl_createDirectory */
+/****************************************************************************/
+
+oslFileError SAL_CALL osl_createDirectory( rtl_uString* ustrDirectoryURL )
+{
+ char path[PATH_MAX];
+ oslFileError eRet;
+
+ OSL_ASSERT( ustrDirectoryURL );
+
+ /* convert directory url to system path */
+ eRet = FileURLToPath( path, PATH_MAX, ustrDirectoryURL );
+ if( eRet != osl_File_E_None )
+ return eRet;
+
+#ifdef MACOSX
+ if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
+ return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif/* MACOSX */
+
+ return osl_psz_createDirectory( path );
+}
+
+/****************************************************************************/
+/* osl_removeDirectory */
+/****************************************************************************/
+
+oslFileError SAL_CALL osl_removeDirectory( rtl_uString* ustrDirectoryURL )
+{
+ char path[PATH_MAX];
+ oslFileError eRet;
+
+ OSL_ASSERT( ustrDirectoryURL );
+
+ /* convert directory url to system path */
+ eRet = FileURLToPath( path, PATH_MAX, ustrDirectoryURL );
+ if( eRet != osl_File_E_None )
+ return eRet;
+
+#ifdef MACOSX
+ if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
+ return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif/* MACOSX */
+
+ return osl_psz_removeDirectory( path );
+}
+
+/*****************************************
+ * osl_psz_createDirectory
+ ****************************************/
+
+static oslFileError osl_psz_createDirectory( const sal_Char* pszPath )
+{
+ int nRet=0;
+ int mode = S_IRWXU | S_IRWXG | S_IRWXO;
+
+ nRet = mkdir(pszPath,mode);
+
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+ return oslTranslateFileError(OSL_FET_ERROR, nRet);
+ }
+
+ return osl_File_E_None;
+}
+
+/*****************************************
+ * osl_psz_removeDirectory
+ ****************************************/
+
+static oslFileError osl_psz_removeDirectory( const sal_Char* pszPath )
+{
+ int nRet=0;
+
+ nRet = rmdir(pszPath);
+
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+ return oslTranslateFileError(OSL_FET_ERROR, nRet);
+ }
+
+ return osl_File_E_None;
+}
+
+/****************************************************************************/
+/* osl_createDirectoryPath */
+/****************************************************************************/
+
+static int path_make_parent(sal_Unicode* path)
+{
+ int i = rtl_ustr_lastIndexOfChar(path, '/');
+
+ if (i > 0)
+ {
+ *(path + i) = 0;
+ return i;
+ }
+ else
+ return 0;
+}
+
+static int create_dir_with_callback(
+ sal_Unicode* directory_path,
+ oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
+ void* pData)
+{
+ int mode = S_IRWXU | S_IRWXG | S_IRWXO;
+
+ if (osl::mkdir(directory_path, mode) == 0)
+ {
+ if (aDirectoryCreationCallbackFunc)
+ {
+ rtl::OUString url;
+ osl::FileBase::getFileURLFromSystemPath(directory_path, url);
+ aDirectoryCreationCallbackFunc(pData, url.pData);
+ }
+ return 0;
+ }
+ return errno;
+}
+
+static oslFileError create_dir_recursively_(
+ sal_Unicode* dir_path,
+ oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
+ void* pData)
+{
+ OSL_PRECOND((rtl_ustr_getLength(dir_path) > 0) && ((dir_path + (rtl_ustr_getLength(dir_path) - 1)) != (dir_path + rtl_ustr_lastIndexOfChar(dir_path, '/'))), \
+ "Path must not end with a slash");
+
+ int native_err = create_dir_with_callback(
+ dir_path, aDirectoryCreationCallbackFunc, pData);
+
+ if (native_err == 0)
+ return osl_File_E_None;
+
+ if (native_err != ENOENT)
+ return oslTranslateFileError(OSL_FET_ERROR, native_err);
+
+ // we step back until '/a_dir' at maximum because
+ // we should get an error unequal ENOENT when
+ // we try to create 'a_dir' at '/' and would so
+ // return before
+ int pos = path_make_parent(dir_path);
+
+ oslFileError osl_error = create_dir_recursively_(
+ dir_path, aDirectoryCreationCallbackFunc, pData);
+
+ if (osl_File_E_None != osl_error)
+ return osl_error;
+
+ dir_path[pos] = '/';
+
+ return create_dir_recursively_(dir_path, aDirectoryCreationCallbackFunc, pData);
+}
+
+oslFileError SAL_CALL osl_createDirectoryPath(
+ rtl_uString* aDirectoryUrl,
+ oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
+ void* pData)
+{
+ if (aDirectoryUrl == NULL)
+ return osl_File_E_INVAL;
+
+ rtl::OUString sys_path;
+ oslFileError osl_error = osl_getSystemPathFromFileURL_Ex(
+ aDirectoryUrl, &sys_path.pData, sal_False);
+
+ if (osl_error != osl_File_E_None)
+ return osl_error;
+
+ osl::systemPathRemoveSeparator(sys_path);
+
+ // const_cast because sys_path is a local copy which we want to modify inplace instead of
+ // coyp it into another buffer on the heap again
+ return create_dir_recursively_(sys_path.pData->buffer, aDirectoryCreationCallbackFunc, pData);
+}
+
+/******************************************************************************
+ *
+ * C-String Function Declarations
+ *
+ *****************************************************************************/
+
+static oslFileError osl_psz_removeFile(const sal_Char* pszPath);
+static oslFileError osl_psz_copyFile(const sal_Char* pszPath, const sal_Char* pszDestPath);
+static oslFileError osl_psz_moveFile(const sal_Char* pszPath, const sal_Char* pszDestPath);
+
+
+/******************************************************************************
+ *
+ * Static Module Utility Function Declarations
+ *
+ *****************************************************************************/
+
+static oslFileError oslDoCopy(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, mode_t nMode, size_t nSourceSize, int DestFileExists);
+static oslFileError oslChangeFileModes(const sal_Char* pszFileName, mode_t nMode, time_t nAcTime, time_t nModTime, uid_t nUID, gid_t nGID);
+static int oslDoCopyLink(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName);
+static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, size_t nSourceSize, mode_t mode);
+static oslFileError oslDoMoveFile(const sal_Char* pszPath, const sal_Char* pszDestPath);
+
+/****************************************************************************/
+/* osl_moveFile */
+/****************************************************************************/
+
+oslFileError SAL_CALL osl_moveFile( rtl_uString* ustrFileURL, rtl_uString* ustrDestURL )
+{
+ char srcPath[PATH_MAX];
+ char destPath[PATH_MAX];
+ oslFileError eRet;
+
+ OSL_ASSERT( ustrFileURL );
+ OSL_ASSERT( ustrDestURL );
+
+ /* convert source url to system path */
+ eRet = FileURLToPath( srcPath, PATH_MAX, ustrFileURL );
+ if( eRet != osl_File_E_None )
+ return eRet;
+
+ /* convert destination url to system path */
+ eRet = FileURLToPath( destPath, PATH_MAX, ustrDestURL );
+ if( eRet != osl_File_E_None )
+ return eRet;
+
+#ifdef MACOSX
+ if ( macxp_resolveAlias( srcPath, PATH_MAX ) != 0 || macxp_resolveAlias( destPath, PATH_MAX ) != 0 )
+ return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif/* MACOSX */
+
+ return oslDoMoveFile( srcPath, destPath );
+}
+
+/****************************************************************************/
+/* osl_copyFile */
+/****************************************************************************/
+
+oslFileError SAL_CALL osl_copyFile( rtl_uString* ustrFileURL, rtl_uString* ustrDestURL )
+{
+ char srcPath[PATH_MAX];
+ char destPath[PATH_MAX];
+ oslFileError eRet;
+
+ OSL_ASSERT( ustrFileURL );
+ OSL_ASSERT( ustrDestURL );
+
+ /* convert source url to system path */
+ eRet = FileURLToPath( srcPath, PATH_MAX, ustrFileURL );
+ if( eRet != osl_File_E_None )
+ return eRet;
+
+ /* convert destination url to system path */
+ eRet = FileURLToPath( destPath, PATH_MAX, ustrDestURL );
+ if( eRet != osl_File_E_None )
+ return eRet;
+
+#ifdef MACOSX
+ if ( macxp_resolveAlias( srcPath, PATH_MAX ) != 0 || macxp_resolveAlias( destPath, PATH_MAX ) != 0 )
+ return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif/* MACOSX */
+
+ return osl_psz_copyFile( srcPath, destPath );
+}
+
+/****************************************************************************/
+/* osl_removeFile */
+/****************************************************************************/
+
+oslFileError SAL_CALL osl_removeFile( rtl_uString* ustrFileURL )
+{
+ char path[PATH_MAX];
+ oslFileError eRet;
+
+ OSL_ASSERT( ustrFileURL );
+
+ /* convert file url to system path */
+ eRet = FileURLToPath( path, PATH_MAX, ustrFileURL );
+ if( eRet != osl_File_E_None )
+ return eRet;
+
+#ifdef MACOSX
+ if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
+ return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif/* MACOSX */
+
+ return osl_psz_removeFile( path );
+}
+
+/******************************************************************************
+ *
+ * Utility Functions
+ *
+ *****************************************************************************/
+
+/*****************************************
+ * oslDoMoveFile
+ ****************************************/
+
+static oslFileError oslDoMoveFile( const sal_Char* pszPath, const sal_Char* pszDestPath)
+{
+ oslFileError tErr=osl_File_E_invalidError;
+
+ tErr = osl_psz_moveFile(pszPath,pszDestPath);
+ if ( tErr == osl_File_E_None )
+ {
+ return tErr;
+ }
+
+ if ( tErr != osl_File_E_XDEV )
+ {
+ return tErr;
+ }
+
+ tErr=osl_psz_copyFile(pszPath,pszDestPath);
+
+ if ( tErr != osl_File_E_None )
+ {
+ oslFileError tErrRemove;
+ tErrRemove=osl_psz_removeFile(pszDestPath);
+ return tErr;
+ }
+
+ tErr=osl_psz_removeFile(pszPath);
+
+ return tErr;
+}
+
+/*****************************************
+ * osl_psz_removeFile
+ ****************************************/
+static oslFileError osl_psz_removeFile( const sal_Char* pszPath )
+{
+ int nRet=0;
+ struct stat aStat;
+
+ nRet = lstat(pszPath,&aStat);
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+ return oslTranslateFileError(OSL_FET_ERROR, nRet);
+ }
+
+ if ( S_ISDIR(aStat.st_mode) )
+ {
+ return osl_File_E_ISDIR;
+ }
+
+ nRet = unlink(pszPath);
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+ return oslTranslateFileError(OSL_FET_ERROR, nRet);
+ }
+
+ return osl_File_E_None;
+}
+
+/*****************************************
+ * osl_psz_moveFile
+ ****************************************/
+
+static oslFileError osl_psz_moveFile(const sal_Char* pszPath, const sal_Char* pszDestPath)
+{
+
+ int nRet = 0;
+
+ nRet = rename(pszPath,pszDestPath);
+
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+ return oslTranslateFileError(OSL_FET_ERROR, nRet);
+ }
+
+ return osl_File_E_None;
+}
+
+/*****************************************
+ * osl_psz_copyFile
+ ****************************************/
+
+static oslFileError osl_psz_copyFile( const sal_Char* pszPath, const sal_Char* pszDestPath )
+{
+ time_t nAcTime=0;
+ time_t nModTime=0;
+ uid_t nUID=0;
+ gid_t nGID=0;
+ int nRet=0;
+ mode_t nMode=0;
+ struct stat aFileStat;
+ oslFileError tErr=osl_File_E_invalidError;
+ size_t nSourceSize=0;
+ int DestFileExists=1;
+
+ /* mfe: does the source file really exists? */
+ nRet = lstat(pszPath,&aFileStat);
+
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+ return oslTranslateFileError(OSL_FET_ERROR, nRet);
+ }
+
+ /* mfe: we do only copy files here! */
+ if ( S_ISDIR(aFileStat.st_mode) )
+ {
+ return osl_File_E_ISDIR;
+ }
+
+ nSourceSize=(size_t)aFileStat.st_size;
+ nMode=aFileStat.st_mode;
+ nAcTime=aFileStat.st_atime;
+ nModTime=aFileStat.st_mtime;
+ nUID=aFileStat.st_uid;
+ nGID=aFileStat.st_gid;
+
+ nRet = stat(pszDestPath,&aFileStat);
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+
+ if ( nRet == ENOENT )
+ {
+ DestFileExists=0;
+ }
+/* return oslTranslateFileError(nRet);*/
+ }
+
+ /* mfe: the destination file must not be a directory! */
+ if ( nRet == 0 && S_ISDIR(aFileStat.st_mode) )
+ {
+ return osl_File_E_ISDIR;
+ }
+ else
+ {
+ /* mfe: file does not exists or is no dir */
+ }
+
+ tErr = oslDoCopy(pszPath,pszDestPath,nMode,nSourceSize,DestFileExists);
+
+ if ( tErr != osl_File_E_None )
+ {
+ return tErr;
+ }
+
+ /*
+ * mfe: ignore return code
+ * since only the success of the copy is
+ * important
+ */
+ oslChangeFileModes(pszDestPath,nMode,nAcTime,nModTime,nUID,nGID);
+
+ return tErr;
+}
+
+
+/******************************************************************************
+ *
+ * Utility Functions
+ *
+ *****************************************************************************/
+
+/*****************************************
+ * oslDoCopy
+ ****************************************/
+
+#define TMP_DEST_FILE_EXTENSION ".osl-tmp"
+
+static oslFileError oslDoCopy(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, mode_t nMode, size_t nSourceSize, int DestFileExists)
+{
+ int nRet=0;
+ sal_Char pszTmpDestFile[PATH_MAX];
+ size_t size_tmp_dest_buff = sizeof(pszTmpDestFile);
+
+ /* Quick fix for #106048, the whole copy file function seems
+ to be erroneous anyway and needs to be rewritten.
+ Besides osl_copyFile is currently not used from OO/SO code.
+ */
+ memset(pszTmpDestFile, 0, size_tmp_dest_buff);
+
+ if ( DestFileExists )
+ {
+ strncpy(pszTmpDestFile, pszDestFileName, size_tmp_dest_buff - 1);
+
+ if ((strlen(pszTmpDestFile) + strlen(TMP_DEST_FILE_EXTENSION)) >= size_tmp_dest_buff)
+ return osl_File_E_NAMETOOLONG;
+
+ strncat(pszTmpDestFile, TMP_DEST_FILE_EXTENSION, strlen(TMP_DEST_FILE_EXTENSION));
+
+ /* FIXME: what if pszTmpDestFile already exists? */
+ /* with getcanonical??? */
+ nRet=rename(pszDestFileName,pszTmpDestFile);
+ }
+
+ /* mfe: should be S_ISREG */
+ if ( !S_ISLNK(nMode) )
+ {
+ /* copy SourceFile to DestFile */
+ nRet = oslDoCopyFile(pszSourceFileName,pszDestFileName,nSourceSize, nMode);
+ }
+ /* mfe: OK redundant at the moment */
+ else if ( S_ISLNK(nMode) )
+ {
+ nRet = oslDoCopyLink(pszSourceFileName,pszDestFileName);
+ }
+ else
+ {
+ /* mfe: what to do here? */
+ nRet=ENOSYS;
+ }
+
+ if ( nRet > 0 && DestFileExists == 1 )
+ {
+ unlink(pszDestFileName);
+ rename(pszTmpDestFile,pszDestFileName);
+ }
+
+ if ( nRet > 0 )
+ {
+ return oslTranslateFileError(OSL_FET_ERROR, nRet);
+ }
+
+ if ( DestFileExists == 1 )
+ {
+ unlink(pszTmpDestFile);
+ }
+
+ return osl_File_E_None;
+}
+
+/*****************************************
+ * oslChangeFileModes
+ ****************************************/
+
+static oslFileError oslChangeFileModes( const sal_Char* pszFileName, mode_t nMode, time_t nAcTime, time_t nModTime, uid_t nUID, gid_t nGID)
+{
+ int nRet=0;
+ struct utimbuf aTimeBuffer;
+
+ nRet = chmod(pszFileName,nMode);
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+ return oslTranslateFileError(OSL_FET_ERROR, nRet);
+ }
+
+ aTimeBuffer.actime=nAcTime;
+ aTimeBuffer.modtime=nModTime;
+ nRet=utime(pszFileName,&aTimeBuffer);
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+ return oslTranslateFileError(OSL_FET_ERROR, nRet);
+ }
+
+ if ( nUID != getuid() )
+ {
+ nUID=getuid();
+ }
+
+ nRet=chown(pszFileName,nUID,nGID);
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+
+ /* mfe: do not return an error here! */
+ /* return oslTranslateFileError(nRet);*/
+ }
+
+ return osl_File_E_None;
+}
+
+/*****************************************
+ * oslDoCopyLink
+ ****************************************/
+
+static int oslDoCopyLink(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName)
+{
+ int nRet=0;
+
+ /* mfe: if dest file is symbolic link remove the link and place the file instead (hro says so) */
+ /* mfe: if source is a link copy the link and not the file it points to (hro says so) */
+ sal_Char pszLinkContent[PATH_MAX];
+
+ pszLinkContent[0] = '\0';
+
+ nRet = readlink(pszSourceFileName,pszLinkContent,PATH_MAX);
+
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+ return nRet;
+ }
+ else
+ pszLinkContent[ nRet ] = 0;
+
+ nRet = symlink(pszLinkContent,pszDestFileName);
+
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+ return nRet;
+ }
+
+ return 0;
+}
+
+/*****************************************
+ * oslDoCopyFile
+ ****************************************/
+
+static int oslDoCopyFile(const sal_Char* pszSourceFileName, const sal_Char* pszDestFileName, size_t nSourceSize, mode_t mode)
+{
+ int SourceFileFD=0;
+ int DestFileFD=0;
+ int nRet=0;
+ void* pSourceFile=0;
+
+ SourceFileFD=open(pszSourceFileName,O_RDONLY);
+ if ( SourceFileFD < 0 )
+ {
+ nRet=errno;
+ return nRet;
+ }
+
+ DestFileFD=open(pszDestFileName, O_WRONLY | O_CREAT, mode);
+
+ if ( DestFileFD < 0 )
+ {
+ nRet=errno;
+ close(SourceFileFD);
+ return nRet;
+ }
+
+ /* HACK: because memory mapping fails on various
+ platforms if the size of the source file is 0 byte */
+ if (0 == nSourceSize)
+ {
+ close(SourceFileFD);
+ close(DestFileFD);
+ return 0;
+ }
+
+ /* FIXME doCopy: fall back code for systems not having mmap */
+ /* mmap file -- open dest file -- write once -- fsync it */
+ pSourceFile=mmap(0,nSourceSize,PROT_READ,MAP_PRIVATE,SourceFileFD,0);
+
+ if ( pSourceFile == MAP_FAILED )
+ {
+ /* it's important to set nRet before the hack
+ otherwise errno may be changed by lstat */
+ nRet = errno;
+ close(SourceFileFD);
+ close(DestFileFD);
+
+ return nRet;
+ }
+
+ nRet = write(DestFileFD,pSourceFile,nSourceSize);
+
+ /* #112584# if 'write' could not write the requested number of bytes
+ we have to fail of course; because it's not exactly specified if 'write'
+ sets errno if less than requested byte could be written we set nRet
+ explicitly to ENOSPC */
+ if ((nRet < 0) || (nRet != sal::static_int_cast< int >(nSourceSize)))
+ {
+ if (nRet < 0)
+ nRet = errno;
+ else
+ nRet = ENOSPC;
+
+ close(SourceFileFD);
+ close(DestFileFD);
+ munmap((char*)pSourceFile,nSourceSize);
+ return nRet;
+ }
+
+ nRet = munmap((char*)pSourceFile,nSourceSize);
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+ close(SourceFileFD);
+ close(DestFileFD);
+ return nRet;
+ }
+
+ close(SourceFileFD);
+
+ // Removed call to 'fsync' again (#112584#) and instead
+ // evaluate the return value of 'close' in order to detect
+ // and report ENOSPC and other erronous conditions on close
+ if (close(DestFileFD) == -1)
+ return errno;
+ else
+ return 0;
+}
diff --git a/sal/osl/unx/file_stat.cxx b/sal/osl/unx/file_stat.cxx
index 3a710743a1b2..d56c2a1fad6a 100644
--- a/sal/osl/unx/file_stat.cxx
+++ b/sal/osl/unx/file_stat.cxx
@@ -31,39 +31,20 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sal.hxx"
-#ifndef _TYPES_H
-#include <sys/types.h>
-#endif
-
-#ifndef _LIMITS_H
-#include <limits.h>
-#endif
-
-#ifndef _UNISTD_H
-#include <unistd.h>
-#endif
+#include "osl/file.h"
-#ifndef _DIRENT_H
+#include "system.h"
+#include <sys/types.h>
#include <dirent.h>
-#endif
-
-#include <osl/file.h>
-
-#ifndef _ERRNO_H
#include <errno.h>
-#endif
-
-#include <rtl/string.hxx>
-
-#ifndef _OSL_UUNXAPI_H_
-#include "uunxapi.hxx"
-#endif
-#include "file_path_helper.hxx"
-#include "file_error_transl.h"
+#include <limits.h>
+#include <unistd.h>
-#ifdef _DIRENT_HAVE_D_TYPE
#include "file_impl.hxx"
-#endif
+#include "file_error_transl.h"
+#include "file_path_helper.hxx"
+#include "file_url.h"
+#include "uunxapi.hxx"
namespace /* private */
{
@@ -231,19 +212,10 @@ namespace /* private */
/* we only need to call stat or lstat if one of the
following flags is set */
-#ifdef _DIRENT_HAVE_D_TYPE
- inline bool is_stat_call_necessary(sal_uInt32 field_mask, oslDirectoryItemImpl *pImpl)
-#else
- inline bool is_stat_call_necessary(sal_uInt32 field_mask)
-#endif
+ inline bool is_stat_call_necessary(sal_uInt32 field_mask, oslFileType file_type = osl_File_Type_Unknown)
{
return (
-/* on linux the dirent might have d_type */
-#ifdef _DIRENT_HAVE_D_TYPE
- ((field_mask & osl_FileStatus_Mask_Type) && (!pImpl->bHasType || pImpl->DType == DT_UNKNOWN)) ||
-#else
- (field_mask & osl_FileStatus_Mask_Type) ||
-#endif
+ ((field_mask & osl_FileStatus_Mask_Type) && (file_type == osl_File_Type_Unknown)) ||
(field_mask & osl_FileStatus_Mask_Attributes) ||
(field_mask & osl_FileStatus_Mask_CreationTime) ||
(field_mask & osl_FileStatus_Mask_AccessTime) ||
@@ -267,24 +239,18 @@ namespace /* private */
return osl_File_E_None;
}
- inline oslFileError setup_osl_getFileStatus(oslDirectoryItem Item, oslFileStatus* pStat, rtl::OUString& file_path)
+ inline oslFileError setup_osl_getFileStatus(
+ DirectoryItem_Impl * pImpl, oslFileStatus* pStat, rtl::OUString& file_path)
{
- if ((NULL == Item) || (NULL == pStat))
+ if ((NULL == pImpl) || (NULL == pStat))
return osl_File_E_INVAL;
-#ifdef _DIRENT_HAVE_D_TYPE
- file_path = rtl::OUString(reinterpret_cast<rtl_uString*>(((oslDirectoryItemImpl* ) Item)->ustrFilePath));
-#else
- file_path = rtl::OUString(reinterpret_cast<rtl_uString*>(Item));
-#endif
-
+ file_path = rtl::OUString(pImpl->m_ustrFilePath);
OSL_ASSERT(file_path.getLength() > 0);
-
if (file_path.getLength() <= 0)
return osl_File_E_INVAL;
pStat->uValidFields = 0;
-
return osl_File_E_None;
}
@@ -297,8 +263,10 @@ namespace /* private */
oslFileError SAL_CALL osl_getFileStatus(oslDirectoryItem Item, oslFileStatus* pStat, sal_uInt32 uFieldMask)
{
+ DirectoryItem_Impl * pImpl = static_cast< DirectoryItem_Impl* >(Item);
+
rtl::OUString file_path;
- oslFileError osl_error = setup_osl_getFileStatus(Item, pStat, file_path);
+ oslFileError osl_error = setup_osl_getFileStatus(pImpl, pStat, file_path);
if (osl_File_E_None != osl_error)
return osl_error;
@@ -308,13 +276,7 @@ oslFileError SAL_CALL osl_getFileStatus(oslDirectoryItem Item, oslFileStatus* pS
struct stat file_stat;
#endif
-#ifdef _DIRENT_HAVE_D_TYPE
- oslDirectoryItemImpl* pImpl = (oslDirectoryItemImpl*) Item;
- bool bStatNeeded = is_stat_call_necessary(uFieldMask, pImpl);
-#else
- bool bStatNeeded = is_stat_call_necessary(uFieldMask);
-#endif
-
+ bool bStatNeeded = is_stat_call_necessary(uFieldMask, pImpl->getFileType());
if (bStatNeeded && (0 != osl::lstat(file_path, file_stat)))
return oslTranslateFileError(OSL_FET_ERROR, errno);
@@ -338,37 +300,10 @@ oslFileError SAL_CALL osl_getFileStatus(oslDirectoryItem Item, oslFileStatus* pS
#ifdef _DIRENT_HAVE_D_TYPE
else if (uFieldMask & osl_FileStatus_Mask_Type)
{
- OSL_ASSERT(pImpl->bHasType);
-
- switch(pImpl->DType)
- {
- case DT_LNK:
- pStat->eType = osl_File_Type_Link;
- break;
- case DT_DIR:
- pStat->eType = osl_File_Type_Directory;
- break;
- case DT_REG:
- pStat->eType = osl_File_Type_Regular;
- break;
- case DT_FIFO:
- pStat->eType = osl_File_Type_Fifo;
- break;
- case DT_SOCK:
- pStat->eType = osl_File_Type_Socket;
- break;
- case DT_CHR:
- case DT_BLK:
- pStat->eType = osl_File_Type_Special;
- break;
- default:
- OSL_ASSERT(0);
- pStat->eType = osl_File_Type_Unknown;
- }
-
- pStat->uValidFields |= osl_FileStatus_Mask_Type;
+ pStat->eType = pImpl->getFileType();
+ pStat->uValidFields |= osl_FileStatus_Mask_Type;
}
-#endif
+#endif /* _DIRENT_HAVE_D_TYPE */
if (uFieldMask & osl_FileStatus_Mask_FileURL)
{
@@ -386,3 +321,175 @@ oslFileError SAL_CALL osl_getFileStatus(oslDirectoryItem Item, oslFileStatus* pS
return osl_File_E_None;
}
+/****************************************************************************/
+/* osl_setFileAttributes */
+/****************************************************************************/
+
+static oslFileError osl_psz_setFileAttributes( const sal_Char* pszFilePath, sal_uInt64 uAttributes )
+{
+ oslFileError osl_error = osl_File_E_None;
+ mode_t nNewMode = 0;
+
+ OSL_ENSURE(!(osl_File_Attribute_Hidden & uAttributes), "osl_File_Attribute_Hidden doesn't work under Unix");
+
+ if (uAttributes & osl_File_Attribute_OwnRead)
+ nNewMode |= S_IRUSR;
+
+ if (uAttributes & osl_File_Attribute_OwnWrite)
+ nNewMode|=S_IWUSR;
+
+ if (uAttributes & osl_File_Attribute_OwnExe)
+ nNewMode|=S_IXUSR;
+
+ if (uAttributes & osl_File_Attribute_GrpRead)
+ nNewMode|=S_IRGRP;
+
+ if (uAttributes & osl_File_Attribute_GrpWrite)
+ nNewMode|=S_IWGRP;
+
+ if (uAttributes & osl_File_Attribute_GrpExe)
+ nNewMode|=S_IXGRP;
+
+ if (uAttributes & osl_File_Attribute_OthRead)
+ nNewMode|=S_IROTH;
+
+ if (uAttributes & osl_File_Attribute_OthWrite)
+ nNewMode|=S_IWOTH;
+
+ if (uAttributes & osl_File_Attribute_OthExe)
+ nNewMode|=S_IXOTH;
+
+ if (chmod(pszFilePath, nNewMode) < 0)
+ osl_error = oslTranslateFileError(OSL_FET_ERROR, errno);
+
+ return osl_error;
+}
+
+oslFileError SAL_CALL osl_setFileAttributes( rtl_uString* ustrFileURL, sal_uInt64 uAttributes )
+{
+ char path[PATH_MAX];
+ oslFileError eRet;
+
+ OSL_ASSERT( ustrFileURL );
+
+ /* convert file url to system path */
+ eRet = FileURLToPath( path, PATH_MAX, ustrFileURL );
+ if( eRet != osl_File_E_None )
+ return eRet;
+
+#ifdef MACOSX
+ if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
+ return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif/* MACOSX */
+
+ return osl_psz_setFileAttributes( path, uAttributes );
+}
+
+/****************************************************************************/
+/* osl_setFileTime */
+/****************************************************************************/
+
+static oslFileError osl_psz_setFileTime (
+ const sal_Char* pszFilePath,
+ const TimeValue* /*pCreationTime*/,
+ const TimeValue* pLastAccessTime,
+ const TimeValue* pLastWriteTime )
+{
+ int nRet=0;
+ struct utimbuf aTimeBuffer;
+ struct stat aFileStat;
+#ifdef DEBUG_OSL_FILE
+ struct tm* pTM=0;
+#endif
+
+ nRet = lstat(pszFilePath,&aFileStat);
+
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+ return oslTranslateFileError(OSL_FET_ERROR, nRet);
+ }
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"File Times are (in localtime):\n");
+ pTM=localtime(&aFileStat.st_ctime);
+ fprintf(stderr,"CreationTime is '%s'\n",asctime(pTM));
+ pTM=localtime(&aFileStat.st_atime);
+ fprintf(stderr,"AccessTime is '%s'\n",asctime(pTM));
+ pTM=localtime(&aFileStat.st_mtime);
+ fprintf(stderr,"Modification is '%s'\n",asctime(pTM));
+
+ fprintf(stderr,"File Times are (in UTC):\n");
+ fprintf(stderr,"CreationTime is '%s'\n",ctime(&aFileStat.st_ctime));
+ fprintf(stderr,"AccessTime is '%s'\n",ctime(&aTimeBuffer.actime));
+ fprintf(stderr,"Modification is '%s'\n",ctime(&aTimeBuffer.modtime));
+#endif
+
+ if ( pLastAccessTime != 0 )
+ {
+ aTimeBuffer.actime=pLastAccessTime->Seconds;
+ }
+ else
+ {
+ aTimeBuffer.actime=aFileStat.st_atime;
+ }
+
+ if ( pLastWriteTime != 0 )
+ {
+ aTimeBuffer.modtime=pLastWriteTime->Seconds;
+ }
+ else
+ {
+ aTimeBuffer.modtime=aFileStat.st_mtime;
+ }
+
+ /* mfe: Creation time not used here! */
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"File Times are (in localtime):\n");
+ pTM=localtime(&aFileStat.st_ctime);
+ fprintf(stderr,"CreationTime now '%s'\n",asctime(pTM));
+ pTM=localtime(&aTimeBuffer.actime);
+ fprintf(stderr,"AccessTime now '%s'\n",asctime(pTM));
+ pTM=localtime(&aTimeBuffer.modtime);
+ fprintf(stderr,"Modification now '%s'\n",asctime(pTM));
+
+ fprintf(stderr,"File Times are (in UTC):\n");
+ fprintf(stderr,"CreationTime now '%s'\n",ctime(&aFileStat.st_ctime));
+ fprintf(stderr,"AccessTime now '%s'\n",ctime(&aTimeBuffer.actime));
+ fprintf(stderr,"Modification now '%s'\n",ctime(&aTimeBuffer.modtime));
+#endif
+
+ nRet=utime(pszFilePath,&aTimeBuffer);
+ if ( nRet < 0 )
+ {
+ nRet=errno;
+ return oslTranslateFileError(OSL_FET_ERROR, nRet);
+ }
+
+ return osl_File_E_None;
+}
+
+oslFileError SAL_CALL osl_setFileTime (
+ rtl_uString* ustrFileURL,
+ const TimeValue* pCreationTime,
+ const TimeValue* pLastAccessTime,
+ const TimeValue* pLastWriteTime )
+{
+ char path[PATH_MAX];
+ oslFileError eRet;
+
+ OSL_ASSERT( ustrFileURL );
+
+ /* convert file url to system path */
+ eRet = FileURLToPath( path, PATH_MAX, ustrFileURL );
+ if( eRet != osl_File_E_None )
+ return eRet;
+
+#ifdef MACOSX
+ if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
+ return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif/* MACOSX */
+
+ return osl_psz_setFileTime( path, pCreationTime, pLastAccessTime, pLastWriteTime );
+}
diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx
index 1d6b9172bc6d..1bcd2afb4505 100644
--- a/sal/osl/unx/file_url.cxx
+++ b/sal/osl/unx/file_url.cxx
@@ -30,45 +30,31 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sal.hxx"
+
+#include "file_url.h"
+
#include "system.h"
-#ifndef _LIMITS_H
#include <limits.h>
-#endif
-
-#ifndef _ERRNO_H
#include <errno.h>
-#endif
-
-#ifndef _STRINGS_H
#include <strings.h>
-#endif
-
-#ifndef _UNISTD_H
#include <unistd.h>
-#endif
-#include <osl/file.h>
+
+#include "osl/file.hxx"
#include <osl/security.h>
-#include <rtl/uri.h>
#include <osl/diagnose.h>
+#include <osl/thread.h>
+#include <osl/process.h>
+
+#include <rtl/uri.h>
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.h>
+#include "rtl/textcvt.h"
-#ifndef _OSL_TREAD_H_
-#include <osl/thread.h>
-#endif
-#include <osl/file.hxx>
-#include <osl/process.h>
#include "file_error_transl.h"
-
-#ifndef _FILE_URL_H_
-#include "file_url.h"
-#endif
#include "file_path_helper.hxx"
-#ifndef _OSL_UUNXAPI_HXX_
#include "uunxapi.hxx"
-#endif
/***************************************************
@@ -84,16 +70,14 @@
so this code should be consolidated.
**************************************************/
+/************************************************************************
+ * ToDo
+ *
+ * Fix osl_getCanonicalName
+ *
+ ***********************************************************************/
-
-/***************************************************
- * forward
- **************************************************/
-
-extern "C" int UnicodeToText(char *, size_t, const sal_Unicode *, sal_Int32);
-extern "C" int TextToUnicode(const char* text, size_t text_buffer_size, sal_Unicode* unic_text, sal_Int32 unic_text_buffer_size);
-
/***************************************************
* namespace directives
**************************************************/
@@ -151,6 +135,18 @@ static sal_Bool findWrongUsage( const sal_Unicode *path, sal_Int32 len )
*/
/****************************************************************************/
+/* osl_getCanonicalName */
+/****************************************************************************/
+
+oslFileError SAL_CALL osl_getCanonicalName( rtl_uString* ustrFileURL, rtl_uString** pustrValidURL )
+{
+ OSL_ENSURE(0, "osl_getCanonicalName not implemented");
+
+ rtl_uString_newFromString(pustrValidURL, ustrFileURL);
+ return osl_File_E_None;
+}
+
+/****************************************************************************/
/* osl_getSystemPathFromFileURL */
/****************************************************************************/
@@ -850,3 +846,120 @@ oslFileError FileURLToPath(char * buffer, size_t bufLen, rtl_uString* ustrFileUR
return osl_error;
}
+
+/*****************************************************************************
+ * UnicodeToText
+ ****************************************************************************/
+
+namespace /* private */
+{
+ class UnicodeToTextConverter_Impl
+ {
+ rtl_UnicodeToTextConverter m_converter;
+
+ UnicodeToTextConverter_Impl()
+ : m_converter (rtl_createUnicodeToTextConverter (osl_getThreadTextEncoding()))
+ {}
+
+ ~UnicodeToTextConverter_Impl()
+ {
+ rtl_destroyUnicodeToTextConverter (m_converter);
+ }
+ public:
+ static UnicodeToTextConverter_Impl & getInstance()
+ {
+ static UnicodeToTextConverter_Impl g_theConverter;
+ return g_theConverter;
+ }
+
+ sal_Size convert(
+ sal_Unicode const * pSrcBuf, sal_Size nSrcChars, sal_Char * pDstBuf, sal_Size nDstBytes,
+ sal_uInt32 nFlags, sal_uInt32 * pInfo, sal_Size * pSrcCvtChars)
+ {
+ OSL_ASSERT(m_converter != 0);
+ return rtl_convertUnicodeToText (
+ m_converter, 0, pSrcBuf, nSrcChars, pDstBuf, nDstBytes, nFlags, pInfo, pSrcCvtChars);
+ }
+ };
+} // end namespace private
+
+int UnicodeToText( char * buffer, size_t bufLen, const sal_Unicode * uniText, sal_Int32 uniTextLen )
+{
+ sal_uInt32 nInfo = 0;
+ sal_Size nSrcChars = 0;
+
+ sal_Size nDestBytes = UnicodeToTextConverter_Impl::getInstance().convert (
+ uniText, uniTextLen, buffer, bufLen,
+ OUSTRING_TO_OSTRING_CVTFLAGS | RTL_UNICODETOTEXT_FLAGS_FLUSH, &nInfo, &nSrcChars);
+
+ if( nInfo & RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL )
+ {
+ errno = EOVERFLOW;
+ return 0;
+ }
+
+ /* ensure trailing '\0' */
+ buffer[nDestBytes] = '\0';
+ return nDestBytes;
+}
+
+/*****************************************************************************
+ * TextToUnicode
+ ****************************************************************************/
+
+namespace /* private */
+{
+ class TextToUnicodeConverter_Impl
+ {
+ rtl_TextToUnicodeConverter m_converter;
+
+ TextToUnicodeConverter_Impl()
+ : m_converter (rtl_createTextToUnicodeConverter (osl_getThreadTextEncoding()))
+ {}
+
+ ~TextToUnicodeConverter_Impl()
+ {
+ rtl_destroyTextToUnicodeConverter (m_converter);
+ }
+
+ public:
+ static TextToUnicodeConverter_Impl & getInstance()
+ {
+ static TextToUnicodeConverter_Impl g_theConverter;
+ return g_theConverter;
+ }
+
+ sal_Size convert(
+ sal_Char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDstBuf, sal_Size nDstChars,
+ sal_uInt32 nFlags, sal_uInt32 * pInfo, sal_Size * pSrcCvtBytes)
+ {
+ OSL_ASSERT(m_converter != 0);
+ return rtl_convertTextToUnicode (
+ m_converter, 0, pSrcBuf, nSrcBytes, pDstBuf, nDstChars, nFlags, pInfo, pSrcCvtBytes);
+ }
+ };
+} // end namespace private
+
+int TextToUnicode(
+ const char* text,
+ size_t text_buffer_size,
+ sal_Unicode* unic_text,
+ sal_Int32 unic_text_buffer_size)
+{
+ sal_uInt32 nInfo = 0;
+ sal_Size nSrcChars = 0;
+
+ sal_Size nDestBytes = TextToUnicodeConverter_Impl::getInstance().convert(
+ text, text_buffer_size, unic_text, unic_text_buffer_size,
+ OSTRING_TO_OUSTRING_CVTFLAGS | RTL_TEXTTOUNICODE_FLAGS_FLUSH, &nInfo, &nSrcChars);
+
+ if (nInfo & RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL)
+ {
+ errno = EOVERFLOW;
+ return 0;
+ }
+
+ /* ensure trailing '\0' */
+ unic_text[nDestBytes] = '\0';
+ return nDestBytes;
+}
diff --git a/sal/osl/unx/file_url.h b/sal/osl/unx/file_url.h
index 4d89239567c5..721bc9d3d698 100644
--- a/sal/osl/unx/file_url.h
+++ b/sal/osl/unx/file_url.h
@@ -28,43 +28,45 @@
*
************************************************************************/
- /***************************************************
- * Internal header file, declares all functions
- * that are not part of the offical API and are
- * not defined in the osl header files
- **************************************************/
+#ifndef INCLUDED_FILE_URL_H
+#define INCLUDED_FILE_URL_H
- #ifndef _FILE_URL_H_
- #define _FILE_URL_H_
+#include "osl/file.h"
- #ifndef _FILE_H_
- #include <osl/file.h>
- #endif
+#ifdef __cplusplus
+extern "C"
+{
+#endif
- #ifdef __cplusplus
- extern "C"
- {
- #endif
+/**************************************************
+ * osl_getSystemPathFromFileURL_Ex
+ *************************************************/
- /**************************************************
- * _osl_getSystemPathFromFileURL
- *************************************************/
+#define FURL_ALLOW_RELATIVE sal_True
+#define FURL_DENY_RELATIVE sal_False
- #define FURL_ALLOW_RELATIVE sal_True
- #define FURL_DENY_RELATIVE sal_False
+oslFileError osl_getSystemPathFromFileURL_Ex(rtl_uString *ustrFileURL, rtl_uString **pustrSystemPath, sal_Bool bAllowRelative);
- oslFileError osl_getSystemPathFromFileURL_Ex(rtl_uString *ustrFileURL, rtl_uString **pustrSystemPath, sal_Bool bAllowRelative);
+/**************************************************
+ * FileURLToPath
+ *************************************************/
- /**************************************************
- * FileURLToPath
- *************************************************/
+oslFileError FileURLToPath(char * buffer, size_t bufLen, rtl_uString* ustrFileURL);
- oslFileError FileURLToPath(char * buffer, size_t bufLen, rtl_uString* ustrFileURL);
+/***************************************************
+ * UnicodeToText
+ **************************************************/
+int UnicodeToText(char * buffer, size_t bufLen, const sal_Unicode * uniText, sal_Int32 uniTextLen);
- #ifdef __cplusplus
- }
- #endif
+/***************************************************
+ * TextToUniCode
+ **************************************************/
+int TextToUnicode(const char* text, size_t text_buffer_size, sal_Unicode* unic_text, sal_Int32 unic_text_buffer_size);
- #endif /* #define _FILE_URL_H_ */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #define INCLUDED_FILE_URL_H */
diff --git a/sal/osl/unx/file_volume.cxx b/sal/osl/unx/file_volume.cxx
new file mode 100644
index 000000000000..a3b7109123b7
--- /dev/null
+++ b/sal/osl/unx/file_volume.cxx
@@ -0,0 +1,1570 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "osl/file.h"
+
+#include "osl/diagnose.h"
+#include "osl/thread.h"
+#include "rtl/alloc.h"
+
+#include "file_error_transl.h"
+#include "file_url.h"
+#include "system.h"
+
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+#ifdef HAVE_STATFS_H
+#undef HAVE_STATFS_H
+#endif
+
+#if defined(SOLARIS)
+
+#include <sys/mnttab.h>
+#include <sys/statvfs.h>
+#define HAVE_STATFS_H
+#include <sys/fs/ufs_quota.h>
+static const sal_Char* MOUNTTAB="/etc/mnttab";
+
+#elif defined(LINUX)
+
+#include <mntent.h>
+#include <sys/vfs.h>
+#define HAVE_STATFS_H
+#include <sys/quota.h>
+//#include <ctype.h>
+static const sal_Char* MOUNTTAB="/etc/mtab";
+
+#elif defined(NETBSD) || defined(FREEBSD)
+
+#include <sys/param.h>
+#include <sys/ucred.h>
+#include <sys/mount.h>
+#include <ufs/ufs/quota.h>
+//#include <ctype.h>
+#define HAVE_STATFS_H
+
+/* No mounting table on *BSD
+ * This information is stored only in the kernel. */
+/* static const sal_Char* MOUNTTAB="/etc/mtab"; */
+
+#elif defined(IRIX)
+
+#include <mntent.h>
+#include <sys/mount.h>
+#include <sys/statvfs.h>
+#define HAVE_STATFS_H
+#include <sys/quota.h>
+//#include <ctype.h>
+static const sal_Char* MOUNTTAB="/etc/mtab";
+
+#elif defined(MACOSX)
+
+#include <ufs/ufs/quota.h>
+//#include <ctype.h>
+#include <sys/param.h>
+#include <sys/mount.h>
+#define HAVE_STATFS_H
+// static const sal_Char* MOUNTTAB="/etc/mtab";
+
+#endif /* HAVE_STATFS_H */
+
+/************************************************************************
+ * ToDo
+ *
+ * - Fix: check for corresponding struct sizes in exported functions
+ * - check size/use of oslVolumeDeviceHandle
+ * - check size/use of oslVolumeInfo
+ ***********************************************************************/
+/******************************************************************************
+ *
+ * Data Type Definition
+ *
+ ******************************************************************************/
+
+typedef struct _oslVolumeDeviceHandleImpl
+{
+ sal_Char pszMountPoint[PATH_MAX];
+ sal_Char pszFilePath[PATH_MAX];
+ sal_Char pszDevice[PATH_MAX];
+ sal_Char ident[4];
+ sal_uInt32 RefCount;
+} oslVolumeDeviceHandleImpl;
+
+/******************************************************************************
+ *
+ * 'removeable device' aka floppy functions
+ *
+ *****************************************************************************/
+
+static oslVolumeDeviceHandle osl_isFloppyDrive(const sal_Char* pszPath);
+static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy);
+static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy);
+
+#if defined(SOLARIS)
+static sal_Bool osl_isFloppyMounted(sal_Char* pszPath, sal_Char* pszMountPath);
+static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, sal_Char* pBuffer);
+static sal_Bool osl_checkFloppyPath(sal_Char* pszPath, sal_Char* pszFilePath, sal_Char* pszDevicePath);
+#endif /* SOLARIS */
+
+#if defined(LINUX)
+static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice);
+static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem);
+#endif /* LINUX */
+
+
+#if defined(IRIX)
+static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice);
+static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem);
+#endif /* IRIX */
+
+#ifdef DEBUG_OSL_FILE
+static void osl_printFloppyHandle(oslVolumeDeviceHandleImpl* hFloppy);
+#endif /* DEBUG_OSL_FILE */
+
+/******************************************************************************
+ *
+ * C-String Function Declarations
+ *
+ *****************************************************************************/
+
+static oslFileError osl_psz_getVolumeInformation(const sal_Char* , oslVolumeInfo* pInfo, sal_uInt32 uFieldMask);
+
+/****************************************************************************/
+/* osl_getVolumeInformation */
+/****************************************************************************/
+
+oslFileError osl_getVolumeInformation( rtl_uString* ustrDirectoryURL, oslVolumeInfo* pInfo, sal_uInt32 uFieldMask )
+{
+ char path[PATH_MAX];
+ oslFileError eRet;
+
+ OSL_ASSERT( ustrDirectoryURL );
+ OSL_ASSERT( pInfo );
+
+ /* convert directory url to system path */
+ eRet = FileURLToPath( path, PATH_MAX, ustrDirectoryURL );
+ if( eRet != osl_File_E_None )
+ return eRet;
+
+#ifdef MACOSX
+ if ( macxp_resolveAlias( path, PATH_MAX ) != 0 )
+ return oslTranslateFileError( OSL_FET_ERROR, errno );
+#endif/* MACOSX */
+
+ return osl_psz_getVolumeInformation( path, pInfo, uFieldMask);
+}
+
+/******************************************************************************
+ *
+ * C-String Versions of Exported Module Functions
+ *
+ *****************************************************************************/
+
+#ifdef HAVE_STATFS_H
+
+#if defined(FREEBSD) || defined(NETBSD) || defined(MACOSX)
+# define __OSL_STATFS_STRUCT struct statfs
+# define __OSL_STATFS(dir, sfs) statfs((dir), (sfs))
+# define __OSL_STATFS_BLKSIZ(a) ((sal_uInt64)((a).f_bsize))
+# define __OSL_STATFS_TYPENAME(a) ((a).f_fstypename)
+# define __OSL_STATFS_ISREMOTE(a) (((a).f_type & MNT_LOCAL) == 0)
+
+/* always return true if queried for the properties of
+ the file system. If you think this is wrong under any
+ of the target platforms fix it!!!! */
+# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) (1)
+# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) (1)
+#endif /* FREEBSD || NETBSD || MACOSX */
+
+#if defined(LINUX)
+# define __OSL_NFS_SUPER_MAGIC 0x6969
+# define __OSL_SMB_SUPER_MAGIC 0x517B
+# define __OSL_MSDOS_SUPER_MAGIC 0x4d44
+# define __OSL_NTFS_SUPER_MAGIC 0x5346544e
+# define __OSL_STATFS_STRUCT struct statfs
+# define __OSL_STATFS(dir, sfs) statfs((dir), (sfs))
+# define __OSL_STATFS_BLKSIZ(a) ((sal_uInt64)((a).f_bsize))
+# define __OSL_STATFS_IS_NFS(a) (__OSL_NFS_SUPER_MAGIC == (a).f_type)
+# define __OSL_STATFS_IS_SMB(a) (__OSL_SMB_SUPER_MAGIC == (a).f_type)
+# define __OSL_STATFS_ISREMOTE(a) (__OSL_STATFS_IS_NFS((a)) || __OSL_STATFS_IS_SMB((a)))
+# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) ((__OSL_MSDOS_SUPER_MAGIC != (a).f_type) && (__OSL_NTFS_SUPER_MAGIC != (a).f_type))
+# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) ((__OSL_MSDOS_SUPER_MAGIC != (a).f_type))
+#endif /* LINUX */
+
+#if defined(SOLARIS) || defined(IRIX)
+# define __OSL_STATFS_STRUCT struct statvfs
+# define __OSL_STATFS(dir, sfs) statvfs((dir), (sfs))
+# define __OSL_STATFS_BLKSIZ(a) ((sal_uInt64)((a).f_frsize))
+# define __OSL_STATFS_TYPENAME(a) ((a).f_basetype)
+# define __OSL_STATFS_ISREMOTE(a) (rtl_str_compare((a).f_basetype, "nfs") == 0)
+
+/* always return true if queried for the properties of
+ the file system. If you think this is wrong under any
+ of the target platforms fix it!!!! */
+# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) (1)
+# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) (1)
+#endif /* SOLARIS || IRIX*/
+
+# define __OSL_STATFS_INIT(a) (memset(&(a), 0, sizeof(__OSL_STATFS_STRUCT)))
+
+#else /* no statfs available */
+
+# define __OSL_STATFS_STRUCT struct dummy {int i;}
+# define __OSL_STATFS_INIT(a) ((void)0)
+# define __OSL_STATFS(dir, sfs) (1)
+# define __OSL_STATFS_ISREMOTE(sfs) (0)
+# define __OSL_STATFS_IS_CASE_SENSITIVE_FS(a) (1)
+# define __OSL_STATFS_IS_CASE_PRESERVING_FS(a) (1)
+#endif /* HAVE_STATFS_H */
+
+
+static oslFileError osl_psz_getVolumeInformation (
+ const sal_Char* pszDirectory, oslVolumeInfo* pInfo, sal_uInt32 uFieldMask)
+{
+ __OSL_STATFS_STRUCT sfs;
+
+ if (!pInfo)
+ return osl_File_E_INVAL;
+
+ __OSL_STATFS_INIT(sfs);
+
+ pInfo->uValidFields = 0;
+ pInfo->uAttributes = 0;
+
+ if ((__OSL_STATFS(pszDirectory, &sfs)) < 0)
+ {
+ oslFileError result = oslTranslateFileError(OSL_FET_ERROR, errno);
+ return (result);
+ }
+
+ /* FIXME: how to detect the kind of storage (fixed, cdrom, ...) */
+ if (uFieldMask & osl_VolumeInfo_Mask_Attributes)
+ {
+ if (__OSL_STATFS_ISREMOTE(sfs))
+ pInfo->uAttributes |= osl_Volume_Attribute_Remote;
+
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes;
+ }
+
+ if (uFieldMask & osl_VolumeInfo_Mask_FileSystemCaseHandling)
+ {
+ if (__OSL_STATFS_IS_CASE_SENSITIVE_FS(sfs))
+ pInfo->uAttributes |= osl_Volume_Attribute_Case_Sensitive;
+
+ if (__OSL_STATFS_IS_CASE_PRESERVING_FS(sfs))
+ pInfo->uAttributes |= osl_Volume_Attribute_Case_Is_Preserved;
+
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes;
+ }
+
+ pInfo->uTotalSpace = 0;
+ pInfo->uFreeSpace = 0;
+ pInfo->uUsedSpace = 0;
+
+#if defined(__OSL_STATFS_BLKSIZ)
+
+ if ((uFieldMask & osl_VolumeInfo_Mask_TotalSpace) ||
+ (uFieldMask & osl_VolumeInfo_Mask_UsedSpace))
+ {
+ pInfo->uTotalSpace = __OSL_STATFS_BLKSIZ(sfs);
+ pInfo->uTotalSpace *= (sal_uInt64)(sfs.f_blocks);
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_TotalSpace;
+ }
+
+ if ((uFieldMask & osl_VolumeInfo_Mask_FreeSpace) ||
+ (uFieldMask & osl_VolumeInfo_Mask_UsedSpace))
+ {
+ pInfo->uFreeSpace = __OSL_STATFS_BLKSIZ(sfs);
+
+ if (getuid() == 0)
+ pInfo->uFreeSpace *= (sal_uInt64)(sfs.f_bfree);
+ else
+ pInfo->uFreeSpace *= (sal_uInt64)(sfs.f_bavail);
+
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_FreeSpace;
+ }
+
+#endif /* __OSL_STATFS_BLKSIZ */
+
+ if ((pInfo->uValidFields & osl_VolumeInfo_Mask_TotalSpace) &&
+ (pInfo->uValidFields & osl_VolumeInfo_Mask_FreeSpace ))
+ {
+ pInfo->uUsedSpace = pInfo->uTotalSpace - pInfo->uFreeSpace;
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_UsedSpace;
+ }
+
+ pInfo->uMaxNameLength = 0;
+ if (uFieldMask & osl_VolumeInfo_Mask_MaxNameLength)
+ {
+ long nLen = pathconf(pszDirectory, _PC_NAME_MAX);
+ if (nLen > 0)
+ {
+ pInfo->uMaxNameLength = (sal_uInt32)nLen;
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxNameLength;
+ }
+ }
+
+ pInfo->uMaxPathLength = 0;
+ if (uFieldMask & osl_VolumeInfo_Mask_MaxPathLength)
+ {
+ long nLen = pathconf (pszDirectory, _PC_PATH_MAX);
+ if (nLen > 0)
+ {
+ pInfo->uMaxPathLength = (sal_uInt32)nLen;
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxPathLength;
+ }
+ }
+
+#if defined(__OSL_STATFS_TYPENAME)
+
+ if (uFieldMask & osl_VolumeInfo_Mask_FileSystemName)
+ {
+ rtl_string2UString(
+ &(pInfo->ustrFileSystemName),
+ __OSL_STATFS_TYPENAME(sfs),
+ rtl_str_getLength(__OSL_STATFS_TYPENAME(sfs)),
+ osl_getThreadTextEncoding(),
+ OUSTRING_TO_OSTRING_CVTFLAGS);
+ OSL_ASSERT(pInfo->ustrFileSystemName != 0);
+
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_FileSystemName;
+ }
+
+#endif /* __OSL_STATFS_TYPENAME */
+
+ if (uFieldMask & osl_VolumeInfo_Mask_DeviceHandle)
+ {
+ /* FIXME: check also entries in mntent for the device
+ and fill it with correct values */
+
+ *pInfo->pDeviceHandle = osl_isFloppyDrive(pszDirectory);
+
+ if (*pInfo->pDeviceHandle)
+ {
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_DeviceHandle;
+ pInfo->uAttributes |= osl_Volume_Attribute_Removeable;
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes;
+ }
+ }
+ return osl_File_E_None;
+}
+
+/******************************************************************************
+ *
+ * GENERIC FLOPPY FUNCTIONS
+ *
+ *****************************************************************************/
+
+
+/*****************************************
+ * osl_unmountVolumeDevice
+ ****************************************/
+
+oslFileError osl_unmountVolumeDevice( oslVolumeDeviceHandle Handle )
+{
+ oslFileError tErr = osl_File_E_NOSYS;
+
+ tErr = osl_unmountFloppy(Handle);
+
+ /* Perhaps current working directory is set to mount point */
+
+ if ( tErr )
+ {
+ sal_Char *pszHomeDir = getenv("HOME");
+
+ if ( pszHomeDir && strlen( pszHomeDir ) && 0 == chdir( pszHomeDir ) )
+ {
+ /* try again */
+
+ tErr = osl_unmountFloppy(Handle);
+
+ OSL_ENSURE( tErr, "osl_unmountvolumeDevice: CWD was set to volume mount point" );
+ }
+ }
+
+ return tErr;
+}
+
+/*****************************************
+ * osl_automountVolumeDevice
+ ****************************************/
+
+oslFileError osl_automountVolumeDevice( oslVolumeDeviceHandle Handle )
+{
+ oslFileError tErr = osl_File_E_NOSYS;
+
+ tErr = osl_mountFloppy(Handle);
+
+ return tErr;
+}
+
+/*****************************************
+ * osl_getVolumeDeviceMountPath
+ ****************************************/
+static rtl_uString* oslMakeUStrFromPsz(const sal_Char* pszStr, rtl_uString** ustrValid)
+{
+ rtl_string2UString(
+ ustrValid,
+ pszStr,
+ rtl_str_getLength( pszStr ),
+ osl_getThreadTextEncoding(),
+ OUSTRING_TO_OSTRING_CVTFLAGS );
+ OSL_ASSERT(*ustrValid != 0);
+
+ return *ustrValid;
+}
+
+oslFileError osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uString **pstrPath )
+{
+ oslVolumeDeviceHandleImpl* pItem = (oslVolumeDeviceHandleImpl*) Handle;
+ sal_Char Buffer[PATH_MAX];
+
+ Buffer[0] = '\0';
+
+ if ( pItem == 0 || pstrPath == 0 )
+ {
+ return osl_File_E_INVAL;
+ }
+
+ if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
+ {
+ return osl_File_E_INVAL;
+ }
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"Handle is:\n");
+ osl_printFloppyHandle(pItem);
+#endif
+
+ snprintf(Buffer, sizeof(Buffer), "file://%s", pItem->pszMountPoint);
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"Mount Point is: '%s'\n",Buffer);
+#endif
+
+ oslMakeUStrFromPsz(Buffer, pstrPath);
+
+ return osl_File_E_None;
+}
+
+/*****************************************
+ * osl_acquireVolumeDeviceHandle
+ ****************************************/
+
+oslFileError SAL_CALL osl_acquireVolumeDeviceHandle( oslVolumeDeviceHandle Handle )
+{
+ oslVolumeDeviceHandleImpl* pItem =(oslVolumeDeviceHandleImpl*) Handle;
+
+ if ( pItem == 0 )
+ {
+ return osl_File_E_INVAL;
+ }
+
+ if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
+ {
+ return osl_File_E_INVAL;
+ }
+
+ ++pItem->RefCount;
+
+ return osl_File_E_None;
+}
+
+/*****************************************
+ * osl_releaseVolumeDeviceHandle
+ ****************************************/
+
+oslFileError osl_releaseVolumeDeviceHandle( oslVolumeDeviceHandle Handle )
+{
+ oslVolumeDeviceHandleImpl* pItem =(oslVolumeDeviceHandleImpl*) Handle;
+
+ if ( pItem == 0 )
+ {
+ return osl_File_E_INVAL;
+ }
+
+ if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
+ {
+ return osl_File_E_INVAL;
+ }
+
+ --pItem->RefCount;
+
+ if ( pItem->RefCount == 0 )
+ {
+ rtl_freeMemory(pItem);
+ }
+
+ return osl_File_E_None;
+}
+
+#ifndef MACOSX
+
+/*****************************************
+ * osl_newVolumeDeviceHandleImpl
+ ****************************************/
+
+static oslVolumeDeviceHandleImpl* osl_newVolumeDeviceHandleImpl()
+{
+ oslVolumeDeviceHandleImpl* pHandle;
+ const size_t nSizeOfHandle = sizeof(oslVolumeDeviceHandleImpl);
+
+ pHandle = (oslVolumeDeviceHandleImpl*) rtl_allocateMemory (nSizeOfHandle);
+ if (pHandle != NULL)
+ {
+ pHandle->ident[0] = 'O';
+ pHandle->ident[1] = 'V';
+ pHandle->ident[2] = 'D';
+ pHandle->ident[3] = 'H';
+ pHandle->pszMountPoint[0] = '\0';
+ pHandle->pszFilePath[0] = '\0';
+ pHandle->pszDevice[0] = '\0';
+ pHandle->RefCount = 1;
+ }
+ return pHandle;
+}
+
+/*****************************************
+ * osl_freeVolumeDeviceHandleImpl
+ ****************************************/
+
+static void osl_freeVolumeDeviceHandleImpl (oslVolumeDeviceHandleImpl* pHandle)
+{
+ if (pHandle != NULL)
+ rtl_freeMemory (pHandle);
+}
+#endif
+
+/******************************************************************************
+ *
+ * SOLARIS FLOPPY FUNCTIONS
+ *
+ *****************************************************************************/
+
+#if defined(SOLARIS)
+/* compare a given devicename with the typical device names on a Solaris box */
+static sal_Bool
+osl_isAFloppyDevice (const char* pDeviceName)
+{
+ const char* pFloppyDevice [] = {
+ "/dev/fd", "/dev/rfd",
+ "/dev/diskette", "/dev/rdiskette",
+ "/vol/dev/diskette", "/vol/dev/rdiskette"
+ };
+
+ int i;
+ for (i = 0; i < (sizeof(pFloppyDevice)/sizeof(pFloppyDevice[0])); i++)
+ {
+ if (strncmp(pDeviceName, pFloppyDevice[i], strlen(pFloppyDevice[i])) == 0)
+ return sal_True;
+ }
+ return sal_False;
+}
+
+/* compare two directories whether the first may be a parent of the second. this
+ * does not realpath() resolving */
+static sal_Bool
+osl_isAParentDirectory (const char* pParentDir, const char* pSubDir)
+{
+ return strncmp(pParentDir, pSubDir, strlen(pParentDir)) == 0;
+}
+
+/* the name of the routine is obviously silly. But anyway create a
+ * oslVolumeDeviceHandle with correct mount point, device name and a resolved filepath
+ * only if pszPath points to file or directory on a floppy */
+static oslVolumeDeviceHandle
+osl_isFloppyDrive(const sal_Char* pszPath)
+{
+ FILE* pMountTab;
+ struct mnttab aMountEnt;
+ oslVolumeDeviceHandleImpl* pHandle;
+
+ if ((pHandle = osl_newVolumeDeviceHandleImpl()) == NULL)
+ {
+ return NULL;
+ }
+ if (realpath(pszPath, pHandle->pszFilePath) == NULL)
+ {
+ osl_freeVolumeDeviceHandleImpl (pHandle);
+ return NULL;
+ }
+ if ((pMountTab = fopen (MOUNTTAB, "r")) == NULL)
+ {
+ osl_freeVolumeDeviceHandleImpl (pHandle);
+ return NULL;
+ }
+
+ while (getmntent(pMountTab, &aMountEnt) == 0)
+ {
+ const char *pMountPoint = aMountEnt.mnt_mountp;
+ const char *pDevice = aMountEnt.mnt_special;
+ if ( osl_isAParentDirectory (aMountEnt.mnt_mountp, pHandle->pszFilePath)
+ && osl_isAFloppyDevice (aMountEnt.mnt_special))
+ {
+ /* skip the last item for it is the name of the disk */
+ char * pc = strrchr( aMountEnt.mnt_special, '/' );
+
+ if ( NULL != pc )
+ {
+ int len = pc - aMountEnt.mnt_special;
+
+ strncpy( pHandle->pszDevice, aMountEnt.mnt_special, len );
+ pHandle->pszDevice[len] = '\0';
+ }
+ else
+ {
+ /* #106048 use save str functions to avoid buffer overflows */
+ memset(pHandle->pszDevice, 0, sizeof(pHandle->pszDevice));
+ strncpy(pHandle->pszDevice, aMountEnt.mnt_special, sizeof(pHandle->pszDevice) - 1);
+ }
+
+ /* remember the mount point */
+ memset(pHandle->pszMountPoint, 0, sizeof(pHandle->pszMountPoint));
+ strncpy(pHandle->pszMountPoint, aMountEnt.mnt_mountp, sizeof(pHandle->pszMountPoint) - 1);
+
+ fclose (pMountTab);
+ return pHandle;
+ }
+ }
+
+ fclose (pMountTab);
+ osl_freeVolumeDeviceHandleImpl (pHandle);
+ return NULL;
+}
+
+static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy)
+{
+ FILE* pMountTab;
+ struct mnttab aMountEnt;
+ oslVolumeDeviceHandleImpl* pHandle = (oslVolumeDeviceHandleImpl*) hFloppy;
+
+ int nRet=0;
+ sal_Char pszCmd[512] = "";
+
+ if ( pHandle == 0 )
+ return osl_File_E_INVAL;
+
+ /* FIXME: don't know what this is good for */
+ if ( pHandle->ident[0] != 'O' || pHandle->ident[1] != 'V' || pHandle->ident[2] != 'D' || pHandle->ident[3] != 'H' )
+ return osl_File_E_INVAL;
+
+ snprintf(pszCmd, sizeof(pszCmd), "eject -q %s > /dev/null 2>&1", pHandle->pszDevice);
+
+ nRet = system( pszCmd );
+
+ switch ( WEXITSTATUS(nRet) )
+ {
+ case 0:
+ {
+ /* lookup the device in mount tab again */
+ if ((pMountTab = fopen (MOUNTTAB, "r")) == NULL)
+ return osl_File_E_BUSY;
+
+ while (getmntent(pMountTab, &aMountEnt) == 0)
+ {
+ const char *pMountPoint = aMountEnt.mnt_mountp;
+ const char *pDevice = aMountEnt.mnt_special;
+ if ( 0 == strncmp( pHandle->pszDevice, aMountEnt.mnt_special, strlen(pHandle->pszDevice) ) )
+ {
+ memset(pHandle->pszMountPoint, 0, sizeof(pHandle->pszMountPoint));
+ strncpy (pHandle->pszMountPoint, aMountEnt.mnt_mountp, sizeof(pHandle->pszMountPoint) - 1);
+
+ fclose (pMountTab);
+ return osl_File_E_None;
+ }
+ }
+
+ fclose (pMountTab);
+ return osl_File_E_BUSY;
+ }
+ //break; // break not necessary here, see return statements before
+
+ case 1:
+ return osl_File_E_BUSY;
+
+ default:
+ break;
+ }
+
+ return osl_File_E_BUSY;
+}
+
+static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy)
+{
+// FILE* pMountTab;
+// struct mnttab aMountEnt;
+ oslVolumeDeviceHandleImpl* pHandle = (oslVolumeDeviceHandleImpl*) hFloppy;
+
+ int nRet=0;
+ sal_Char pszCmd[512] = "";
+
+ if ( pHandle == 0 )
+ return osl_File_E_INVAL;
+
+ /* FIXME: don't know what this is good for */
+ if ( pHandle->ident[0] != 'O' || pHandle->ident[1] != 'V' || pHandle->ident[2] != 'D' || pHandle->ident[3] != 'H' )
+ return osl_File_E_INVAL;
+
+ snprintf(pszCmd, sizeof(pszCmd), "eject %s > /dev/null 2>&1", pHandle->pszDevice);
+
+ nRet = system( pszCmd );
+
+ switch ( WEXITSTATUS(nRet) )
+ {
+ case 0:
+ {
+ FILE* pMountTab;
+ struct mnttab aMountEnt;
+
+ /* lookup if device is still in mount tab */
+ if ((pMountTab = fopen (MOUNTTAB, "r")) == NULL)
+ return osl_File_E_BUSY;
+
+ while (getmntent(pMountTab, &aMountEnt) == 0)
+ {
+ const char *pMountPoint = aMountEnt.mnt_mountp;
+ const char *pDevice = aMountEnt.mnt_special;
+ if ( 0 == strncmp( pHandle->pszDevice, aMountEnt.mnt_special, strlen(pHandle->pszDevice) ) )
+ {
+ fclose (pMountTab);
+ return osl_File_E_BUSY;
+ }
+ }
+
+ fclose (pMountTab);
+ pHandle->pszMountPoint[0] = 0;
+ return osl_File_E_None;
+ }
+
+ //break; //break not necessary, see return statements before
+
+ case 1:
+ return osl_File_E_NODEV;
+
+ case 4:
+ pHandle->pszMountPoint[0] = 0;
+ return osl_File_E_None;
+
+ default:
+ break;
+ }
+
+ return osl_File_E_BUSY;
+}
+
+#endif /* SOLARIS */
+
+/******************************************************************************
+ *
+ * LINUX FLOPPY FUNCTIONS
+ *
+ *****************************************************************************/
+
+#if defined(LINUX)
+static oslVolumeDeviceHandle
+osl_isFloppyDrive (const sal_Char* pszPath)
+{
+ oslVolumeDeviceHandleImpl* pItem = osl_newVolumeDeviceHandleImpl();
+ if (osl_getFloppyMountEntry(pszPath, pItem))
+ return (oslVolumeDeviceHandle) pItem;
+
+ osl_freeVolumeDeviceHandleImpl (pItem);
+ return 0;
+}
+#endif /* LINUX */
+
+#if defined(LINUX)
+static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy)
+{
+ sal_Bool bRet = sal_False;
+ oslVolumeDeviceHandleImpl* pItem=0;
+ int nRet;
+ sal_Char pszCmd[PATH_MAX];
+ const sal_Char* pszMountProg = "mount";
+ sal_Char* pszSuDo = 0;
+ sal_Char* pszTmp = 0;
+
+ pszCmd[0] = '\0';
+
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"In osl_mountFloppy\n");
+#endif
+
+ pItem = (oslVolumeDeviceHandleImpl*) hFloppy;
+
+ if ( pItem == 0 )
+ {
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_mountFloppy [pItem == 0]\n");
+#endif
+
+ return osl_File_E_INVAL;
+ }
+
+ if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
+ {
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_mountFloppy [invalid handle]\n");
+#endif
+ return osl_File_E_INVAL;
+ }
+
+ bRet = osl_isFloppyMounted(pItem);
+ if ( bRet == sal_True )
+ {
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"detected mounted floppy at '%s'\n",pItem->pszMountPoint);
+#endif
+ return osl_File_E_BUSY;
+ }
+
+ /* mfe: we can't use the mount(2) system call!!! */
+ /* even if we are root */
+ /* since mtab is not updated!!! */
+ /* but we need it to be updated */
+ /* some "magic" must be done */
+
+/* nRet = mount(pItem->pszDevice,pItem->pszMountPoint,0,0,0); */
+/* if ( nRet != 0 ) */
+/* { */
+/* nRet=errno; */
+/* #ifdef DEBUG_OSL_FILE */
+/* perror("mount"); */
+/* #endif */
+/* } */
+
+ pszTmp = getenv("SAL_MOUNT_MOUNTPROG");
+ if ( pszTmp != 0 )
+ {
+ pszMountProg=pszTmp;
+ }
+
+ pszTmp=getenv("SAL_MOUNT_SU_DO");
+ if ( pszTmp != 0 )
+ {
+ pszSuDo=pszTmp;
+ }
+
+ if ( pszSuDo != 0 )
+ {
+ snprintf(pszCmd, sizeof(pszCmd), "%s %s %s %s",pszSuDo,pszMountProg,pItem->pszDevice,pItem->pszMountPoint);
+ }
+ else
+ {
+ snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszMountProg,pItem->pszMountPoint);
+ }
+
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"executing '%s'\n",pszCmd);
+#endif
+
+ nRet = system(pszCmd);
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"call returned '%i'\n",nRet);
+ fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet));
+#endif
+
+
+ switch ( WEXITSTATUS(nRet) )
+ {
+ case 0:
+ nRet=0;
+ break;
+
+ case 2:
+ nRet=EPERM;
+ break;
+
+ case 4:
+ nRet=ENOENT;
+ break;
+
+ case 8:
+ nRet=EINTR;
+ break;
+
+ case 16:
+ nRet=EPERM;
+ break;
+
+ case 32:
+ nRet=EBUSY;
+ break;
+
+ case 64:
+ nRet=EAGAIN;
+ break;
+
+ default:
+ nRet=EBUSY;
+ break;
+ }
+
+ return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet));
+}
+#endif /* LINUX */
+
+
+#if defined(LINUX)
+static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy)
+{
+ oslVolumeDeviceHandleImpl* pItem=0;
+ int nRet=0;
+ sal_Char pszCmd[PATH_MAX];
+ sal_Char* pszTmp = 0;
+ sal_Char* pszSuDo = 0;
+ const sal_Char* pszUmountProg = "umount";
+
+ pszCmd[0] = '\0';
+
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"In osl_unmountFloppy\n");
+#endif
+
+ pItem = (oslVolumeDeviceHandleImpl*) hFloppy;
+
+ if ( pItem == 0 )
+ {
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_unmountFloppy [pItem==0]\n");
+#endif
+ return osl_File_E_INVAL;
+ }
+
+ if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
+ {
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_unmountFloppy [invalid handle]\n");
+#endif
+ return osl_File_E_INVAL;
+ }
+
+ /* mfe: we can't use the umount(2) system call!!! */
+ /* even if we are root */
+ /* since mtab is not updated!!! */
+ /* but we need it to be updated */
+ /* some "magic" must be done */
+
+/* nRet=umount(pItem->pszDevice); */
+/* if ( nRet != 0 ) */
+/* { */
+/* nRet = errno; */
+
+/* #ifdef DEBUG_OSL_FILE */
+/* perror("mount"); */
+/* #endif */
+/* } */
+
+
+ pszTmp = getenv("SAL_MOUNT_UMOUNTPROG");
+ if ( pszTmp != 0 )
+ {
+ pszUmountProg=pszTmp;
+ }
+
+ pszTmp = getenv("SAL_MOUNT_SU_DO");
+ if ( pszTmp != 0 )
+ {
+ pszSuDo=pszTmp;
+ }
+
+ if ( pszSuDo != 0 )
+ {
+ snprintf(pszCmd, sizeof(pszCmd), "%s %s %s",pszSuDo,pszUmountProg,pItem->pszMountPoint);
+ }
+ else
+ {
+ snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszUmountProg,pItem->pszMountPoint);
+ }
+
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"executing '%s'\n",pszCmd);
+#endif
+
+ nRet = system(pszCmd);
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"call returned '%i'\n",nRet);
+ fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet));
+#endif
+
+ switch ( WEXITSTATUS(nRet) )
+ {
+ case 0:
+ nRet=0;
+ break;
+
+ default:
+ nRet=EBUSY;
+ break;
+ }
+
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_unmountFloppy [ok]\n");
+#endif
+
+ return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet));
+
+/* return osl_File_E_None;*/
+}
+
+#endif /* LINUX */
+
+#if defined(LINUX)
+static sal_Bool
+osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem)
+{
+ struct mntent* pMountEnt;
+ FILE* pMountTab;
+
+ pMountTab = setmntent (MOUNTTAB, "r");
+ if (pMountTab == 0)
+ return sal_False;
+
+ while ((pMountEnt = getmntent(pMountTab)) != 0)
+ {
+ if ( strncmp(pMountEnt->mnt_dir, pszPath, strlen(pMountEnt->mnt_dir)) == 0
+ && strncmp(pMountEnt->mnt_fsname, "/dev/fd", strlen("/dev/fd")) == 0)
+ {
+ memset(pItem->pszMountPoint, 0, sizeof(pItem->pszMountPoint));
+ strncpy(pItem->pszMountPoint, pMountEnt->mnt_dir, sizeof(pItem->pszMountPoint) - 1);
+
+ memset(pItem->pszFilePath, 0, sizeof(pItem->pszFilePath));
+ strncpy(pItem->pszFilePath, pMountEnt->mnt_dir, sizeof(pItem->pszFilePath) - 1);
+
+ memset(pItem->pszDevice, 0, sizeof(pItem->pszDevice));
+ strncpy(pItem->pszDevice, pMountEnt->mnt_fsname, sizeof(pItem->pszDevice) - 1);
+
+ endmntent (pMountTab);
+ return sal_True;
+ }
+ }
+
+ endmntent (pMountTab);
+ return sal_False;
+}
+#endif /* LINUX */
+
+#if defined(LINUX)
+static sal_Bool
+osl_isFloppyMounted (oslVolumeDeviceHandleImpl* pDevice)
+{
+ oslVolumeDeviceHandleImpl aItem;
+
+ if ( osl_getFloppyMountEntry (pDevice->pszMountPoint, &aItem)
+ && strcmp (aItem.pszMountPoint, pDevice->pszMountPoint) == 0
+ && strcmp (aItem.pszDevice, pDevice->pszDevice) == 0)
+ {
+ return sal_True;
+ }
+ return sal_False;
+}
+#endif /* LINUX */
+
+/******************************************************************************
+ *
+ * IRIX FLOPPY FUNCTIONS
+ *
+ *****************************************************************************/
+
+#if defined(IRIX)
+static oslVolumeDeviceHandle osl_isFloppyDrive(const sal_Char* pszPath)
+{
+ oslVolumeDeviceHandleImpl* pItem = osl_newVolumeDeviceHandleImpl ();
+ sal_Bool bRet = sal_False;
+
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"In osl_isFloppyDrive\n");
+#endif
+
+ bRet=osl_getFloppyMountEntry(pszPath,pItem);
+
+ if ( bRet == sal_False )
+ {
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_isFloppyDrive [not a floppy]\n");
+#endif
+ rtl_freeMemory(pItem);
+ return 0;
+ }
+
+
+#ifdef DEBUG_OSL_FILE
+ osl_printFloppyHandle(pItem);
+#endif
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_isFloppyDrive [ok]\n");
+#endif
+
+ return (oslVolumeDeviceHandle) pItem;
+}
+
+
+static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy)
+{
+ sal_Bool bRet = sal_False;
+ oslVolumeDeviceHandleImpl* pItem=0;
+ int nRet;
+ sal_Char pszCmd[PATH_MAX];
+ sal_Char* pszMountProg = "mount";
+ sal_Char* pszSuDo = 0;
+ sal_Char* pszTmp = 0;
+
+ pszCmd[0] = '\0';
+
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"In osl_mountFloppy\n");
+#endif
+
+ pItem = (oslVolumeDeviceHandleImpl*) hFloppy;
+
+ if ( pItem == 0 )
+ {
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_mountFloppy [pItem == 0]\n");
+#endif
+
+ return osl_File_E_INVAL;
+ }
+
+ if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
+ {
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_mountFloppy [invalid handle]\n");
+#endif
+ return osl_File_E_INVAL;
+ }
+
+ bRet = osl_isFloppyMounted(pItem);
+ if ( bRet == sal_True )
+ {
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"detected mounted floppy at '%s'\n",pItem->pszMountPoint);
+#endif
+ return osl_File_E_BUSY;
+ }
+
+ /* mfe: we can't use the mount(2) system call!!! */
+ /* even if we are root */
+ /* since mtab is not updated!!! */
+ /* but we need it to be updated */
+ /* some "magic" must be done */
+
+/* nRet = mount(pItem->pszDevice,pItem->pszMountPoint,0,0,0); */
+/* if ( nRet != 0 ) */
+/* { */
+/* nRet=errno; */
+/* #ifdef DEBUG_OSL_FILE */
+/* perror("mount"); */
+/* #endif */
+/* } */
+
+ pszTmp = getenv("SAL_MOUNT_MOUNTPROG");
+ if ( pszTmp != 0 )
+ {
+ pszMountProg=pszTmp;
+ }
+
+ pszTmp=getenv("SAL_MOUNT_SU_DO");
+ if ( pszTmp != 0 )
+ {
+ pszSuDo=pszTmp;
+ }
+
+ if ( pszSuDo != 0 )
+ {
+ snprintf(pszCmd, sizeof(pszCmd), "%s %s %s %s",pszSuDo,pszMountProg,pItem->pszDevice,pItem->pszMountPoint);
+ }
+ else
+ {
+ snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszMountProg,pItem->pszMountPoint);
+ }
+
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"executing '%s'\n",pszCmd);
+#endif
+
+ nRet = system(pszCmd);
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"call returned '%i'\n",nRet);
+ fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet));
+#endif
+
+
+ switch ( WEXITSTATUS(nRet) )
+ {
+ case 0:
+ nRet=0;
+ break;
+
+ case 2:
+ nRet=EPERM;
+ break;
+
+ case 4:
+ nRet=ENOENT;
+ break;
+
+ case 8:
+ nRet=EINTR;
+ break;
+
+ case 16:
+ nRet=EPERM;
+ break;
+
+ case 32:
+ nRet=EBUSY;
+ break;
+
+ case 64:
+ nRet=EAGAIN;
+ break;
+
+ default:
+ nRet=EBUSY;
+ break;
+ }
+
+ return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet));
+}
+
+static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy)
+{
+ oslVolumeDeviceHandleImpl* pItem=0;
+ int nRet=0;
+ sal_Char pszCmd[PATH_MAX];
+ sal_Char* pszTmp = 0;
+ sal_Char* pszSuDo = 0;
+ sal_Char* pszUmountProg = "umount";
+
+ pszCmd[0] = '\0';
+
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"In osl_unmountFloppy\n");
+#endif
+
+ pItem = (oslVolumeDeviceHandleImpl*) hFloppy;
+
+ if ( pItem == 0 )
+ {
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_unmountFloppy [pItem==0]\n");
+#endif
+ return osl_File_E_INVAL;
+ }
+
+ if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
+ {
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_unmountFloppy [invalid handle]\n");
+#endif
+ return osl_File_E_INVAL;
+ }
+
+ /* mfe: we can't use the umount(2) system call!!! */
+ /* even if we are root */
+ /* since mtab is not updated!!! */
+ /* but we need it to be updated */
+ /* some "magic" must be done */
+
+/* nRet=umount(pItem->pszDevice); */
+/* if ( nRet != 0 ) */
+/* { */
+/* nRet = errno; */
+
+/* #ifdef DEBUG_OSL_FILE */
+/* perror("mount"); */
+/* #endif */
+/* } */
+
+
+ pszTmp = getenv("SAL_MOUNT_UMOUNTPROG");
+ if ( pszTmp != 0 )
+ {
+ pszUmountProg=pszTmp;
+ }
+
+ pszTmp = getenv("SAL_MOUNT_SU_DO");
+ if ( pszTmp != 0 )
+ {
+ pszSuDo=pszTmp;
+ }
+
+ if ( pszSuDo != 0 )
+ {
+ snprintf(pszCmd, sizeof(pszCmd), "%s %s %s",pszSuDo,pszUmountProg,pItem->pszMountPoint);
+ }
+ else
+ {
+ snprintf(pszCmd, sizeof(pszCmd), "%s %s",pszUmountProg,pItem->pszMountPoint);
+ }
+
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"executing '%s'\n",pszCmd);
+#endif
+
+ nRet = system(pszCmd);
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"call returned '%i'\n",nRet);
+ fprintf(stderr,"exit status is '%i'\n", WEXITSTATUS(nRet));
+#endif
+
+ switch ( WEXITSTATUS(nRet) )
+ {
+ case 0:
+ nRet=0;
+ break;
+
+ default:
+ nRet=EBUSY;
+ break;
+ }
+
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_unmountFloppy [ok]\n");
+#endif
+
+ return ((0 == nRet) ? oslTranslateFileError(OSL_FET_SUCCESS, nRet) : oslTranslateFileError(OSL_FET_ERROR, nRet));
+
+/* return osl_File_E_None;*/
+}
+
+static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem)
+{
+ struct mntent* pMountEnt=0;
+ sal_Char buffer[PATH_MAX];
+ FILE* mntfile=0;
+ int nRet=0;
+
+ buffer[0] = '\0';
+
+ mntfile = setmntent(MOUNTTAB,"r");
+
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"In osl_getFloppyMountEntry\n");
+#endif
+
+ memset(buffer, 0, sizeof(buffer));
+ strncpy(buffer, pszPath, sizeof(buffer) - 1);
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"Checking mount of %s\n",buffer);
+#endif
+
+
+ if ( mntfile == 0 )
+ {
+ nRet=errno;
+#ifdef DEBUG_OSL_FILE
+ perror("mounttab");
+#endif
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_getFloppyMountEntry [mntfile]\n");
+#endif
+ return sal_False;
+ }
+
+ pMountEnt=getmntent(mntfile);
+ while ( pMountEnt != 0 )
+ {
+#ifdef DEBUG_OSL_FILE
+/* fprintf(stderr,"mnt_fsname : %s\n",pMountEnt->mnt_fsname); */
+/* fprintf(stderr,"mnt_dir : %s\n",pMountEnt->mnt_dir); */
+/* fprintf(stderr,"mnt_type : %s\n",pMountEnt->mnt_type);*/
+#endif
+ if ( strcmp(pMountEnt->mnt_dir,buffer) == 0 &&
+ strncmp(pMountEnt->mnt_fsname,"/dev/fd",strlen("/dev/fd")) == 0 )
+ {
+
+ memset(pItem->pszMountPoint, 0, sizeof(pItem->pszMountPoint));
+ strncpy(pItem->pszMountPoint, pMountEnt->mnt_dir, sizeof(pItem->pszMountPoint) - 1);
+
+ memset(pItem->pszFilePath, 0, sizeof(pItem->pszFilePath));
+ strncpy(pItem->pszFilePath, pMountEnt->mnt_dir, sizeof(pItem->pszFilePath) - 1);
+
+ memset(pItem->pszDevice, 0, sizeof(pItem->pszDevice));
+ strncpy(pItem->pszDevice, pMountEnt->mnt_fsname, sizeof(pItem->pszDevice) - 1);
+
+ fclose(mntfile);
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"Mount Point found '%s'\n",pItem->pszMountPoint);
+#endif
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_getFloppyMountEntry [found]\n");
+#endif
+ return sal_True;
+ }
+#ifdef DEBUG_OSL_FILE
+/* fprintf(stderr,"=================\n");*/
+#endif
+ pMountEnt=getmntent(mntfile);
+ }
+
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_getFloppyMountEntry [not found]\n");
+#endif
+
+ fclose(mntfile);
+ return sal_False;
+}
+
+static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice)
+{
+ sal_Char buffer[PATH_MAX];
+ oslVolumeDeviceHandleImpl* pItem=0;
+ sal_Bool bRet=0;
+
+ buffer[0] = '\0';
+
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"In osl_isFloppyMounted\n");
+#endif
+
+ pItem = osl_newVolumeDeviceHandleImpl ();
+ if ( pItem == 0 )
+ return osl_File_E_NOMEM;
+
+ memset(buffer, 0, sizeof(buffer));
+ strncpy(buffer, pDevice->pszMountPoint, sizeof(buffer) - 1);
+
+#ifdef DEBUG_OSL_FILE
+ fprintf(stderr,"Checking mount of %s\n",buffer);
+#endif
+
+ bRet = osl_getFloppyMountEntry(buffer,pItem);
+
+ if ( bRet == sal_False )
+ {
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_isFloppyMounted [not mounted]\n");
+#endif
+ return sal_False;
+ }
+
+ if (strcmp(pItem->pszMountPoint, pDevice->pszMountPoint) == 0 &&
+ strcmp(pItem->pszDevice,pDevice->pszDevice) == 0)
+ {
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_isFloppyMounted [is mounted]\n");
+#endif
+ rtl_freeMemory(pItem);
+ return sal_True;
+ }
+
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Out osl_isFloppyMounted [may be EBUSY]\n");
+#endif
+
+ rtl_freeMemory(pItem);
+ return sal_False;
+}
+#endif /* IRIX */
+
+
+/* NetBSD floppy functions have to be added here. Until we have done that,
+ * we use the MACOSX definitions for nonexistent floppy.
+ * */
+
+/******************************************************************************
+ *
+ * MAC OS X FLOPPY FUNCTIONS
+ *
+ *****************************************************************************/
+
+#if (defined(MACOSX) || defined(NETBSD) || defined(FREEBSD))
+static oslVolumeDeviceHandle osl_isFloppyDrive(const sal_Char* pszPath)
+{
+ return NULL;
+}
+#endif /* MACOSX */
+
+#if ( defined(MACOSX) || defined(NETBSD) || defined(FREEBSD))
+static oslFileError osl_mountFloppy(oslVolumeDeviceHandle hFloppy)
+{
+ return osl_File_E_BUSY;
+}
+#endif /* MACOSX */
+
+#if ( defined(MACOSX) || defined(NETBSD) || defined(FREEBSD))
+static oslFileError osl_unmountFloppy(oslVolumeDeviceHandle hFloppy)
+{
+ return osl_File_E_BUSY;
+}
+#endif /* MACOSX */
+
+#if ( defined(NETBSD) || defined(FREEBSD) )
+static sal_Bool osl_getFloppyMountEntry(const sal_Char* pszPath, oslVolumeDeviceHandleImpl* pItem)
+{
+ return sal_False;
+}
+#endif /* NETBSD || FREEBSD */
+
+#if ( defined(NETBSD) || defined(FREEBSD) )
+static sal_Bool osl_isFloppyMounted(oslVolumeDeviceHandleImpl* pDevice)
+{
+ return sal_False;
+}
+#endif /* NETBSD || FREEBSD */
+
+
+#ifdef DEBUG_OSL_FILE
+static void osl_printFloppyHandle(oslVolumeDeviceHandleImpl* pItem)
+{
+ if (pItem == 0 )
+ {
+ fprintf(stderr,"NULL Handle\n");
+ return;
+ }
+ if ( pItem->ident[0] != 'O' || pItem->ident[1] != 'V' || pItem->ident[2] != 'D' || pItem->ident[3] != 'H' )
+ {
+#ifdef TRACE_OSL_FILE
+ fprintf(stderr,"Invalid Handle]\n");
+#endif
+ return;
+ }
+
+
+ fprintf(stderr,"MountPoint : '%s'\n",pItem->pszMountPoint);
+ fprintf(stderr,"FilePath : '%s'\n",pItem->pszFilePath);
+ fprintf(stderr,"Device : '%s'\n",pItem->pszDevice);
+
+ return;
+}
+#endif
diff --git a/sal/osl/unx/makefile.mk b/sal/osl/unx/makefile.mk
index 1717d836e647..0e728c29dbcd 100644
--- a/sal/osl/unx/makefile.mk
+++ b/sal/osl/unx/makefile.mk
@@ -68,18 +68,20 @@ SLOFILES= $(SLO)$/conditn.obj \
$(SLO)$/security.obj \
$(SLO)$/profile.obj \
$(SLO)$/time.obj \
- $(SLO)$/file.obj \
$(SLO)$/signal.obj \
$(SLO)$/pipe.obj \
$(SLO)$/system.obj \
$(SLO)$/util.obj \
$(SLO)$/tempfile.obj\
+ $(SLO)$/file.obj \
+ $(SLO)$/file_misc.obj \
$(SLO)$/file_url.obj\
$(SLO)$/file_error_transl.obj\
$(SLO)$/file_path_helper.obj\
+ $(SLO)$/file_stat.obj \
+ $(SLO)$/file_volume.obj \
$(SLO)$/uunxapi.obj\
$(SLO)$/process_impl.obj\
- $(SLO)$/file_stat.obj \
$(SLO)$/salinit.obj
#.IF "$(UPDATER)"=="YES"
@@ -96,18 +98,20 @@ OBJFILES= $(OBJ)$/conditn.obj \
$(OBJ)$/security.obj \
$(OBJ)$/profile.obj \
$(OBJ)$/time.obj \
- $(OBJ)$/file.obj \
$(OBJ)$/signal.obj \
$(OBJ)$/pipe.obj \
$(OBJ)$/system.obj \
$(OBJ)$/util.obj \
$(OBJ)$/tempfile.obj\
+ $(OBJ)$/file.obj \
+ $(OBJ)$/file_misc.obj \
$(OBJ)$/file_url.obj\
$(OBJ)$/file_error_transl.obj\
$(OBJ)$/file_path_helper.obj\
+ $(OBJ)$/file_stat.obj \
+ $(OBJ)$/file_volume.obj \
$(OBJ)$/uunxapi.obj\
$(OBJ)$/process_impl.obj\
- $(OBJ)$/file_stat.obj \
$(OBJ)$/salinit.obj
#.ENDIF
diff --git a/sal/osl/unx/process.c b/sal/osl/unx/process.c
index e5faf46548a6..a1f47cdf76a5 100644
--- a/sal/osl/unx/process.c
+++ b/sal/osl/unx/process.c
@@ -466,7 +466,7 @@ static void ChildStatusProc(void *pData)
if ((pid = fork()) == 0)
{
/* Child */
- close(channel[0]);
+ if (channel[0] != -1) close(channel[0]);
if ((data.m_uid != (uid_t)-1) && ((data.m_uid != getuid()) || (data.m_gid != getgid())))
{
@@ -500,32 +500,32 @@ static void ChildStatusProc(void *pData)
/* Connect std IO to pipe ends */
/* Write end of stdInput not used in child process */
- close( stdInput[1] );
+ if (stdInput[1] != -1) close( stdInput[1] );
/* Read end of stdOutput not used in child process */
- close( stdOutput[0] );
+ if (stdOutput[0] != -1) close( stdOutput[0] );
/* Read end of stdError not used in child process */
- close( stdError[0] );
+ if (stdError[0] != -1) close( stdError[0] );
/* Redirect pipe ends to std IO */
if ( stdInput[0] != STDIN_FILENO )
{
dup2( stdInput[0], STDIN_FILENO );
- close( stdInput[0] );
+ if (stdInput[0] != -1) close( stdInput[0] );
}
if ( stdOutput[1] != STDOUT_FILENO )
{
dup2( stdOutput[1], STDOUT_FILENO );
- close( stdOutput[1] );
+ if (stdOutput[1] != -1) close( stdOutput[1] );
}
if ( stdError[1] != STDERR_FILENO )
{
dup2( stdError[1], STDERR_FILENO );
- close( stdError[1] );
+ if (stdError[1] != -1) close( stdError[1] );
}
pid=execv(data.m_pszArgs[0], (sal_Char **)data.m_pszArgs);
@@ -539,7 +539,7 @@ static void ChildStatusProc(void *pData)
/* if we reach here, something went wrong */
write(channel[1], &errno, sizeof(errno));
- close(channel[1]);
+ if (channel[1] != -1) close(channel[1]);
_exit(255);
}
@@ -547,12 +547,12 @@ static void ChildStatusProc(void *pData)
{ /* Parent */
int status;
- close(channel[1]);
+ if (channel[1] != -1) close(channel[1]);
/* Close unused pipe ends */
- close( stdInput[0] );
- close( stdOutput[1] );
- close( stdError[1] );
+ if (stdInput[0] != -1) close( stdInput[0] );
+ if (stdOutput[1] != -1) close( stdOutput[1] );
+ if (stdError[1] != -1) close( stdError[1] );
while (((i = read(channel[0], &status, sizeof(status))) < 0))
{
@@ -560,7 +560,7 @@ static void ChildStatusProc(void *pData)
break;
}
- close(channel[0]);
+ if (channel[0] != -1) close(channel[0]);
if ((pid > 0) && (i == 0))
@@ -646,9 +646,9 @@ static void ChildStatusProc(void *pData)
if ( pdata->m_pErrorRead )
*pdata->m_pErrorRead = NULL;
- close( stdInput[1] );
- close( stdOutput[0] );
- close( stdError[0] );
+ if (stdInput[1] != -1) close( stdInput[1] );
+ if (stdOutput[0] != -1) close( stdOutput[0] );
+ if (stdError[0] != -1) close( stdError[0] );
//if pid > 0 then a process was created, even if it later failed
//e.g. bash searching for a command to execute, and we still
@@ -1124,15 +1124,6 @@ struct osl_procStat
unsigned long nswap; /* ? */
unsigned long cnswap; /* ? */
- /* from 'statm' */
- long size; /* numbers of pages in memory */
- long resident; /* number of resident pages */
- long share; /* number of shared pages */
- long trs; /* text resident size */
- long lrs; /* library resident size */
- long drs; /* data resident size */
- long dt; /* ditry pages */
-
/* from 'status' */
int ruid; /* real uid */
int euid; /* effective uid */
@@ -1155,9 +1146,10 @@ struct osl_procStat
osl_getProcStat
*********************************************/
-void osl_getProcStat(pid_t pid, struct osl_procStat* procstat)
+sal_Bool osl_getProcStat(pid_t pid, struct osl_procStat* procstat)
{
int fd = 0;
+ sal_Bool bRet = sal_False;
char name[PATH_MAX + 1];
snprintf(name, sizeof(name), "/proc/%u/stat", pid);
@@ -1166,11 +1158,13 @@ void osl_getProcStat(pid_t pid, struct osl_procStat* procstat)
char* tmp=0;
char prstatbuf[512];
memset(prstatbuf,0,512);
- read(fd,prstatbuf,511);
+ bRet = read(fd,prstatbuf,511) == 511;
close(fd);
/*printf("%s\n\n",prstatbuf);*/
+ if (!bRet)
+ return sal_False;
tmp = strrchr(prstatbuf, ')');
*tmp = '\0';
@@ -1198,57 +1192,35 @@ void osl_getProcStat(pid_t pid, struct osl_procStat* procstat)
&procstat->wchan, &procstat->nswap, &procstat->cnswap
);
}
-}
-
-/**********************************************
- osl_getProcStatm
- *********************************************/
-
-void osl_getProcStatm(pid_t pid, struct osl_procStat* procstat)
-{
- int fd = 0;
- char name[PATH_MAX + 1];
- snprintf(name, sizeof(name), "/proc/%u/statm", pid);
-
- if ((fd = open(name,O_RDONLY)) >=0 )
- {
- char prstatmbuf[512];
- memset(prstatmbuf,0,512);
- read(fd,prstatmbuf,511);
-
- close(fd);
-
- /* printf("\n\n%s\n\n",prstatmbuf);*/
-
- sscanf(prstatmbuf,"%li %li %li %li %li %li %li",
- &procstat->size, &procstat->resident, &procstat->share,
- &procstat->trs, &procstat->lrs, &procstat->drs,
- &procstat->dt
- );
- }
+ return bRet;
}
/**********************************************
osl_getProcStatus
*********************************************/
-void osl_getProcStatus(pid_t pid, struct osl_procStat* procstat)
+sal_Bool osl_getProcStatus(pid_t pid, struct osl_procStat* procstat)
{
int fd = 0;
char name[PATH_MAX + 1];
snprintf(name, sizeof(name), "/proc/%u/status", pid);
+ sal_Bool bRet = sal_False;
+
if ((fd = open(name,O_RDONLY)) >=0 )
{
char* tmp=0;
char prstatusbuf[512];
memset(prstatusbuf,0,512);
- read(fd,prstatusbuf,511);
+ bRet = read(fd,prstatusbuf,511) == 511;
close(fd);
/* printf("\n\n%s\n\n",prstatusbuf);*/
+ if (!bRet)
+ return sal_False;
+
tmp = strstr(prstatusbuf,"Uid:");
if(tmp)
{
@@ -1290,6 +1262,7 @@ void osl_getProcStatus(pid_t pid, struct osl_procStat* procstat)
);
}
}
+ return bRet;
}
#endif
@@ -1439,56 +1412,54 @@ oslProcessError SAL_CALL osl_getProcessInfo(oslProcess Process, oslProcessData F
#elif defined(LINUX)
-/* int fd = 0;*/
- struct osl_procStat procstat;
- memset(&procstat,0,sizeof(procstat));
+ if ( (Fields & osl_Process_CPUTIMES) || (Fields & osl_Process_HEAPUSAGE) )
+ {
+ struct osl_procStat procstat;
+ memset(&procstat,0,sizeof(procstat));
- osl_getProcStat(pid, &procstat);
- osl_getProcStatm(pid, &procstat);
- osl_getProcStatus(pid, &procstat);
+ if ( (Fields & osl_Process_CPUTIMES) && osl_getProcStat(pid, &procstat) )
+ {
+ /*
+ * mfe:
+ * We calculate only time of the process proper.
+ * Threads are processes, we do not consider their time here!
+ * (For this, cutime and cstime should be used, it seems not
+ * to work in 2.0.36)
+ */
+
+ long clktck;
+ unsigned long hz;
+ unsigned long userseconds;
+ unsigned long systemseconds;
+
+ clktck = sysconf(_SC_CLK_TCK);
+ if (clktck < 0) {
+ return osl_Process_E_Unknown;
+ }
+ hz = (unsigned long) clktck;
- if ( Fields & osl_Process_CPUTIMES)
- {
- /*
- * mfe:
- * We calculate only time of the process proper.
- * Threads are processes, we do not consider their time here!
- * (For this, cutime and cstime should be used, it seems not
- * to work in 2.0.36)
- */
-
- long clktck;
- unsigned long hz;
- unsigned long userseconds;
- unsigned long systemseconds;
-
- clktck = sysconf(_SC_CLK_TCK);
- if (clktck < 0) {
- return osl_Process_E_Unknown;
- }
- hz = (unsigned long) clktck;
+ userseconds = procstat.utime/hz;
+ systemseconds = procstat.stime/hz;
- userseconds = procstat.utime/hz;
- systemseconds = procstat.stime/hz;
+ pInfo->UserTime.Seconds = userseconds;
+ pInfo->UserTime.Nanosec = procstat.utime - (userseconds * hz);
+ pInfo->SystemTime.Seconds = systemseconds;
+ pInfo->SystemTime.Nanosec = procstat.stime - (systemseconds * hz);
- pInfo->UserTime.Seconds = userseconds;
- pInfo->UserTime.Nanosec = procstat.utime - (userseconds * hz);
- pInfo->SystemTime.Seconds = systemseconds;
- pInfo->SystemTime.Nanosec = procstat.stime - (systemseconds * hz);
+ pInfo->Fields |= osl_Process_CPUTIMES;
+ }
- pInfo->Fields |= osl_Process_CPUTIMES;
- }
+ if ( (Fields & osl_Process_HEAPUSAGE) && osl_getProcStatus(pid, &procstat) )
+ {
+ /*
+ * mfe:
+ * vm_data (found in status) shows the size of the data segment
+ * it a rough approximation of the core heap size
+ */
+ pInfo->HeapUsage = procstat.vm_data*1024;
- if (Fields & osl_Process_HEAPUSAGE)
- {
- /*
- * mfe:
- * vm_data (found in status) shows the size of the data segment
- * it a rough approximation of the core heap size
- */
- pInfo->HeapUsage = procstat.vm_data*1024;
-
- pInfo->Fields |= osl_Process_HEAPUSAGE;
+ pInfo->Fields |= osl_Process_HEAPUSAGE;
+ }
}
return (pInfo->Fields == Fields) ? osl_Process_E_None : osl_Process_E_Unknown;
diff --git a/sal/osl/unx/signal.c b/sal/osl/unx/signal.c
index 77633dd81269..35884e11c9ba 100644
--- a/sal/osl/unx/signal.c
+++ b/sal/osl/unx/signal.c
@@ -46,6 +46,7 @@
#ifdef LINUX
#include <execinfo.h>
+#include <link.h>
#define INCLUDE_BACKTRACE
#define STACKTYPE "Linux"
#endif
@@ -392,6 +393,88 @@ static int fputs_xml( const char *string, FILE *stream )
#define REPORTENV_PARAM "-crashreportenv:"
+#if defined SAL_ENABLE_CRASH_REPORT && defined INCLUDE_BACKTRACE && \
+ defined LINUX
+
+typedef struct
+{
+ const char *name;
+ ElfW(Off) offset;
+} dynamic_entry;
+
+static int
+callback(struct dl_phdr_info *info, size_t size, void *data)
+{
+ const ElfW(Phdr) *pDynamic = NULL;
+
+ if (size == sizeof(struct dl_phdr_info))
+ {
+ int i;
+ for (i = 0; i < info->dlpi_phnum; ++i)
+ {
+ if (info->dlpi_phdr[i].p_type == PT_DYNAMIC)
+ {
+ pDynamic = &(info->dlpi_phdr[i]);
+ break;
+ }
+ }
+ }
+
+ if (pDynamic)
+ {
+ char buffer[100];
+ int len;
+ char exe[PATH_MAX];
+ const char *dsoname = info->dlpi_name;
+
+ dynamic_entry* entry = (dynamic_entry*)data;
+
+ if (strcmp(dsoname, "") == 0)
+ {
+ snprintf(buffer, sizeof(buffer), "/proc/%d/exe", getpid());
+ if ((len = readlink(buffer, exe, PATH_MAX)) != -1)
+ {
+ exe[len] = '\0';
+ dsoname = exe;
+ }
+ }
+
+ if (strcmp(dsoname, entry->name) == 0)
+ {
+ entry->offset = pDynamic->p_offset;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+/* Get the location of the .dynamic section offset for the given elf file.
+ * i.e. same as the "Offset" value shown for DYNAMIC from readelf -l foo
+ *
+ * We want to know this value so that if the binaries have been modifed
+ * by prelink then we can still process the call stack on server side
+ * by comparing this value to that of an "un-prelinked but known to be
+ * otherwise equivalent" version of those binaries and adjust the call
+ * stack addresses by the differences between .dynamic addresses so as
+ * to be able to map the prelinked addresses back to the unprelinked
+ * addresses
+ *
+ * cmc@openoffice.org
+ */
+static ElfW(Off)
+dynamic_section_offset(const char *name)
+{
+ dynamic_entry entry;
+
+ entry.name = name;
+ entry.offset = 0;
+
+ dl_iterate_phdr(callback, &entry);
+
+ return entry.offset;
+}
+#endif
+
static int ReportCrash( int Signal )
{
#ifdef SAL_ENABLE_CRASH_REPORT
@@ -572,6 +655,11 @@ static int ReportCrash( int Signal )
if ( dl_info.dli_fbase && dl_info.dli_fname )
{
+#ifdef LINUX
+ ElfW(Off) dynamic_offset = dynamic_section_offset(dl_info.dli_fname);
+ fprintf( stackout, " 0x%" SAL_PRI_SIZET "x:", dynamic_offset);
+#endif
+
fprintf( stackout, " %s + 0x%" SAL_PRI_PTRDIFFT "x",
dl_info.dli_fname,
(char*)stackframes[iFrame] - (char*)dl_info.dli_fbase
@@ -583,6 +671,10 @@ static int ReportCrash( int Signal )
if ( dli_fdir )
fprintf( xmlout, " path=\"%s\"", dli_fdir );
+
+#ifdef LINUX
+ fprintf( xmlout, " dynamicoffset=\"0x%" SAL_PRI_SIZET "x\"", dynamic_offset );
+#endif
}
else
fprintf( stackout, " ????????" );
diff --git a/sal/osl/w32/MAKEFILE.MK b/sal/osl/w32/MAKEFILE.MK
index e6a33854366d..cd52ef549c8d 100644
--- a/sal/osl/w32/MAKEFILE.MK
+++ b/sal/osl/w32/MAKEFILE.MK
@@ -78,6 +78,10 @@ SLOFILES= $(SLO)$/conditn.obj \
$(SLO)$/pipe.obj \
$(SLO)$/util.obj \
$(SLO)$/file.obj\
+ $(SLO)$/file_dirvol.obj\
+ $(SLO)$/file_error.obj\
+ $(SLO)$/file_url.obj\
+ $(SLO)$/tempfile.obj\
$(SLO)$/path_helper.obj\
$(SLO)$/procimpl.obj \
$(SLO)$/salinit.obj
@@ -101,6 +105,10 @@ OBJFILES= $(OBJ)$/conditn.obj \
$(OBJ)$/pipe.obj \
$(OBJ)$/util.obj \
$(OBJ)$/file.obj\
+ $(OBJ)$/file_dirvol.obj\
+ $(OBJ)$/file_error.obj\
+ $(OBJ)$/file_url.obj\
+ $(OBJ)$/tempfile.obj\
$(OBJ)$/path_helper.obj\
$(OBJ)$/procimpl.obj \
$(OBJ)$/salinit.obj
diff --git a/sal/osl/w32/diagnose.c b/sal/osl/w32/diagnose.c
index 6a67c1aa5b0f..b2d22808dcd7 100644
--- a/sal/osl/w32/diagnose.c
+++ b/sal/osl/w32/diagnose.c
@@ -92,7 +92,10 @@ void SAL_CALL osl_trace(const sal_Char* lpszFormat, ...)
sal_Char szMessage[512];
szMessage[sizeof(szMessage)-1] = 0;
written = _vsnprintf( szMessage, sizeof(szMessage) - 2, lpszFormat, args );
- szMessage[ written == -1 ? sizeof(szMessage) - 2 : written ] = '\n';
+ if ( written == -1 )
+ written = sizeof(szMessage) - 2;
+ szMessage[ written++ ] = '\n';
+ szMessage[ written ] = 0;
OutputDebugString( szMessage );
}
diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx
index 7ba66ed3e69c..b6a7c64ee873 100644
--- a/sal/osl/w32/file.cxx
+++ b/sal/osl/w32/file.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: file.cxx,v $
- * $Revision: 1.19 $
+ * $Revision: 1.0 $
*
* This file is part of OpenOffice.org.
*
@@ -34,26 +34,19 @@
#define UNICODE
#define _UNICODE
#define _WIN32_WINNT 0x0500
-#include "systools\win32\uwinapi.h"
+#include "systools/win32/uwinapi.h"
-#include "path_helper.hxx"
+#include "osl/file.hxx"
-#include "sal/types.h"
+#include "file_url.h"
+#include "file_error.h"
-#include "osl/file.hxx"
#include "osl/diagnose.h"
-#include "rtl/ustring.hxx"
#include "rtl/alloc.h"
-#include "rtl/tencinfo.h"
-#include "osl/thread.h"
-#include "osl/mutex.h"
#include "rtl/byteseq.h"
-#include "osl/time.h"
-//#include <rtl/logfile.h>
-#include <stdio.h>
+#include "rtl/ustring.hxx"
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include <stdio.h>
#include <tchar.h>
#ifdef __MINGW32__
@@ -61,2635 +54,700 @@
#include <ctype.h>
#endif
-#include <malloc.h>
#include <algorithm>
#include <limits>
#ifdef max /* conflict w/ std::numeric_limits<T>::max() */
#undef max
#endif
-
-//#####################################################
-// BEGIN global
-//#####################################################
-
-extern "C" oslMutex g_CurrentDirectoryMutex; /* Initialized in dllentry.c */
-oslMutex g_CurrentDirectoryMutex;
-
-//#####################################################
-extern "C" BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime)
-{
- SYSTEMTIME BaseSysTime;
- FILETIME BaseFileTime;
- FILETIME FTime;
- __int64 localTime;
- BOOL fSuccess = FALSE;
-
- BaseSysTime.wYear = 1970;
- BaseSysTime.wMonth = 1;
- BaseSysTime.wDayOfWeek = 0;
- BaseSysTime.wDay = 1;
- BaseSysTime.wHour = 0;
- BaseSysTime.wMinute = 0;
- BaseSysTime.wSecond = 0;
- BaseSysTime.wMilliseconds = 0;
-
- if (cpTimeVal==NULL)
- return fSuccess;
-
- if ( SystemTimeToFileTime(&BaseSysTime, &BaseFileTime) )
- {
- __int64 timeValue;
- localTime=cpTimeVal->Seconds*(__int64)10000000+cpTimeVal->Nanosec/100;
- *(__int64 *)&FTime=localTime;
- fSuccess = 0 <= (timeValue= *((__int64 *)&BaseFileTime) + *((__int64 *) &FTime));
- if (fSuccess)
- *(__int64 *)pFTime=timeValue;
- }
- return fSuccess;
-}
-
-//#####################################################
-extern "C" BOOL FileTimeToTimeValue(const FILETIME *cpFTime, TimeValue *pTimeVal)
-{
- SYSTEMTIME BaseSysTime;
- FILETIME BaseFileTime;
- BOOL fSuccess = FALSE; /* Assume failure */
-
- BaseSysTime.wYear = 1970;
- BaseSysTime.wMonth = 1;
- BaseSysTime.wDayOfWeek = 0;
- BaseSysTime.wDay = 1;
- BaseSysTime.wHour = 0;
- BaseSysTime.wMinute = 0;
- BaseSysTime.wSecond = 0;
- BaseSysTime.wMilliseconds = 0;
-
- if ( SystemTimeToFileTime(&BaseSysTime, &BaseFileTime) )
- {
- __int64 Value;
-
- fSuccess = 0 <= (Value = *((__int64 *)cpFTime) - *((__int64 *)&BaseFileTime));
-
- if ( fSuccess )
- {
- pTimeVal->Seconds = (unsigned long) (Value / 10000000L);
- pTimeVal->Nanosec = (unsigned long)((Value % 10000000L) * 100);
- }
- }
- return fSuccess;
-}
-
-//#####################################################
-extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle(HANDLE hFile)
-{
- if ( IsValidHandle(hFile) )
- return (oslFileHandle)hFile;
- else
- return NULL;
-}
-
-//#####################################################
-// End global
-//#####################################################
-
-
-using namespace osl;
-
-#define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0])))
-
-// Allocate n number of t's on the stack return a pointer to it in p
-#ifdef __MINGW32__
-#define STACK_ALLOC(p, t, n) (p) = reinterpret_cast<t*>(_alloca((n)*sizeof(t)));
-#else
-#define STACK_ALLOC(p, t, n) __try {(p) = reinterpret_cast<t*>(_alloca((n)*sizeof(t)));} \
- __except(EXCEPTION_EXECUTE_HANDLER) {(p) = NULL;}
-#endif
-
-#if OSL_DEBUG_LEVEL > 0
-#define OSL_ENSURE_FILE( cond, msg, file ) ( (cond) ? (void)0 : _osl_warnFile( msg, file ) )
-#else
-#define OSL_ENSURE_FILE( cond, msg, file ) ((void)0)
+#ifdef min
+#undef min
#endif
-#define PATHTYPE_ERROR 0
-#define PATHTYPE_RELATIVE 1
-#define PATHTYPE_ABSOLUTE_UNC 2
-#define PATHTYPE_ABSOLUTE_LOCAL 3
-#define PATHTYPE_MASK_TYPE 0xFF
-#define PATHTYPE_IS_VOLUME 0x0100
-#define PATHTYPE_IS_SERVER 0x0200
-
-#define VALIDATEPATH_NORMAL 0x0000
-#define VALIDATEPATH_ALLOW_WILDCARDS 0x0001
-#define VALIDATEPATH_ALLOW_ELLIPSE 0x0002
-#define VALIDATEPATH_ALLOW_RELATIVE 0x0004
-#define VALIDATEPATH_ALLOW_UNC 0x0008
-
-#define WSTR_SYSTEM_ROOT_PATH L"\\\\.\\"
-
-typedef struct {
- UINT uType;
-
- union {
- WIN32_FIND_DATA FindData;
- TCHAR cDriveString[MAX_PATH];
- };
- TCHAR szFullPath[MAX_PATH];
- BOOL bFullPathNormalized;
- int nRefCount;
-}DirectoryItem_Impl;
-
-#define DIRECTORYTYPE_LOCALROOT 0
-#define DIRECTORYTYPE_NETROOT 1
-#define DIRECTORYTYPE_NETRESORCE 2
-#define DIRECTORYTYPE_FILESYSTEM 3
-
-#define DIRECTORYITEM_DRIVE 0
-#define DIRECTORYITEM_FILE 1
-#define DIRECTORYITEM_SERVER 2
-
-typedef struct {
- UINT uType;
- union {
- HANDLE hDirectory;
- HANDLE hEnumDrives;
- };
- TCHAR szDirectoryPath[MAX_PATH];
-} Directory_Impl;
-
-/* Different types of paths */
-typedef enum _PATHTYPE
+//##################################################################
+// File handle implementation
+//##################################################################
+struct FileHandle_Impl
{
- PATHTYPE_SYNTAXERROR = 0,
- PATHTYPE_NETROOT,
- PATHTYPE_NETSERVER,
- PATHTYPE_VOLUME,
- PATHTYPE_FILE
-} PATHTYPE;
-
+ HANDLE m_hFile;
-namespace /* private */
-{
- // forward
- void _osl_warnFile(const char*, rtl_uString*);
- oslFileError SAL_CALL _osl_getFileURLFromSystemPath(rtl_uString* , rtl_uString**);
- DWORD WINAPI IsValidFilePath(rtl_uString*, LPCTSTR*, DWORD, rtl_uString**);
- HANDLE WINAPI OpenLogicalDrivesEnum(void);
- BOOL WINAPI EnumLogicalDrives(HANDLE, LPTSTR);
- BOOL WINAPI CloseLogicalDrivesEnum(HANDLE);
- HANDLE WINAPI OpenDirectory(LPCTSTR);
- BOOL WINAPI CloseDirectory(HANDLE);
- BOOL WINAPI EnumDirectory(HANDLE, LPWIN32_FIND_DATA);
- DWORD WINAPI GetCaseCorrectPathName(LPCTSTR, LPTSTR, DWORD);
- oslFileError SAL_CALL _osl_getSystemPathFromFileURL(rtl_uString*, rtl_uString**, sal_Bool);
-
- /* OS error to errno values mapping table */
- struct errentry {
- unsigned long oscode; /* OS return value */
- int errnocode; /* System V error code */
+ /** State
+ */
+ enum StateBits
+ {
+ STATE_SEEKABLE = 1, /* open() sets, iff regular file */
+ STATE_READABLE = 2, /* open() sets, read() requires */
+ STATE_WRITEABLE = 4, /* open() sets, write() requires */
+ STATE_MODIFIED = 8 /* write() sets, flush() resets */
};
+ int m_state;
- struct errentry errtable[] = {
- { ERROR_SUCCESS, osl_File_E_None }, /* 0 */
- { ERROR_INVALID_FUNCTION, osl_File_E_INVAL }, /* 1 */
- { ERROR_FILE_NOT_FOUND, osl_File_E_NOENT }, /* 2 */
- { ERROR_PATH_NOT_FOUND, osl_File_E_NOENT }, /* 3 */
- { ERROR_TOO_MANY_OPEN_FILES, osl_File_E_MFILE }, /* 4 */
- { ERROR_ACCESS_DENIED, osl_File_E_ACCES }, /* 5 */
- { ERROR_INVALID_HANDLE, osl_File_E_BADF }, /* 6 */
- { ERROR_ARENA_TRASHED, osl_File_E_NOMEM }, /* 7 */
- { ERROR_NOT_ENOUGH_MEMORY, osl_File_E_NOMEM }, /* 8 */
- { ERROR_INVALID_BLOCK, osl_File_E_NOMEM }, /* 9 */
- { ERROR_BAD_ENVIRONMENT, osl_File_E_2BIG }, /* 10 */
- { ERROR_BAD_FORMAT, osl_File_E_NOEXEC }, /* 11 */
- { ERROR_INVALID_ACCESS, osl_File_E_INVAL }, /* 12 */
- { ERROR_INVALID_DATA, osl_File_E_INVAL }, /* 13 */
- { ERROR_INVALID_DRIVE, osl_File_E_NOENT }, /* 15 */
- { ERROR_CURRENT_DIRECTORY, osl_File_E_ACCES }, /* 16 */
- { ERROR_NOT_SAME_DEVICE, osl_File_E_XDEV }, /* 17 */
- { ERROR_NO_MORE_FILES, osl_File_E_NOENT }, /* 18 */
- { ERROR_NOT_READY, osl_File_E_NOTREADY }, /* 21 */
- { ERROR_LOCK_VIOLATION, osl_File_E_ACCES }, /* 33 */
- { ERROR_BAD_NETPATH, osl_File_E_NOENT }, /* 53 */
- { ERROR_NETWORK_ACCESS_DENIED, osl_File_E_ACCES }, /* 65 */
- { ERROR_BAD_NET_NAME, osl_File_E_NOENT }, /* 67 */
- { ERROR_FILE_EXISTS, osl_File_E_EXIST }, /* 80 */
- { ERROR_CANNOT_MAKE, osl_File_E_ACCES }, /* 82 */
- { ERROR_FAIL_I24, osl_File_E_ACCES }, /* 83 */
- { ERROR_INVALID_PARAMETER, osl_File_E_INVAL }, /* 87 */
- { ERROR_NO_PROC_SLOTS, osl_File_E_AGAIN }, /* 89 */
- { ERROR_DRIVE_LOCKED, osl_File_E_ACCES }, /* 108 */
- { ERROR_BROKEN_PIPE, osl_File_E_PIPE }, /* 109 */
- { ERROR_DISK_FULL, osl_File_E_NOSPC }, /* 112 */
- { ERROR_INVALID_TARGET_HANDLE, osl_File_E_BADF }, /* 114 */
- { ERROR_INVALID_HANDLE, osl_File_E_INVAL }, /* 124 */
- { ERROR_WAIT_NO_CHILDREN, osl_File_E_CHILD }, /* 128 */
- { ERROR_CHILD_NOT_COMPLETE, osl_File_E_CHILD }, /* 129 */
- { ERROR_DIRECT_ACCESS_HANDLE, osl_File_E_BADF }, /* 130 */
- { ERROR_NEGATIVE_SEEK, osl_File_E_INVAL }, /* 131 */
- { ERROR_SEEK_ON_DEVICE, osl_File_E_ACCES }, /* 132 */
- { ERROR_DIR_NOT_EMPTY, osl_File_E_NOTEMPTY }, /* 145 */
- { ERROR_NOT_LOCKED, osl_File_E_ACCES }, /* 158 */
- { ERROR_BAD_PATHNAME, osl_File_E_NOENT }, /* 161 */
- { ERROR_MAX_THRDS_REACHED, osl_File_E_AGAIN }, /* 164 */
- { ERROR_LOCK_FAILED, osl_File_E_ACCES }, /* 167 */
- { ERROR_ALREADY_EXISTS, osl_File_E_EXIST }, /* 183 */
- { ERROR_FILENAME_EXCED_RANGE, osl_File_E_NOENT }, /* 206 */
- { ERROR_NESTING_NOT_ALLOWED, osl_File_E_AGAIN }, /* 215 */
- { ERROR_DIRECTORY, osl_File_E_NOENT }, /* 267 */
- { ERROR_NOT_ENOUGH_QUOTA, osl_File_E_NOMEM }, /* 1816 */
- { ERROR_UNEXP_NET_ERR, osl_File_E_NETWORK } /* 59 */
- };
+ sal_uInt64 m_size; /* file size */
+ LONGLONG m_offset; /* physical offset from begin of file */
+ LONGLONG m_filepos; /* logical offset from begin of file */
- /* The following two constants must be the minimum and maximum
- values in the (contiguous) range of osl_File_E_xec Failure errors. */
- #define MIN_EXEC_ERROR ERROR_INVALID_STARTING_CODESEG
- #define MAX_EXEC_ERROR ERROR_INFLOOP_IN_RELOC_CHAIN
+ LONGLONG m_bufptr; /* buffer offset from begin of file */
+ SIZE_T m_buflen; /* buffer filled [0, m_bufsiz - 1] */
- /* These are the low and high value in the range of errors that are
- access violations */
- #define MIN_EACCES_RANGE ERROR_WRITE_PROTECT
- #define MAX_EACCES_RANGE ERROR_SHARING_BUFFER_EXCEEDED
+ SIZE_T m_bufsiz;
+ sal_uInt8 * m_buffer;
- //#####################################################
- oslFileError MapError(DWORD dwError)
- {
- for (int i = 0; i < ELEMENTS_OF_ARRAY(errtable); ++i )
- {
- if (dwError == errtable[i].oscode)
- return static_cast<oslFileError>(errtable[i].errnocode);
- }
+ explicit FileHandle_Impl (HANDLE hFile);
+ ~FileHandle_Impl();
- /* The error code wasn't in the table. We check for a range of
- osl_File_E_ACCES errors or exec failure errors (ENOEXEC).
- Otherwise osl_File_E_INVAL is returned. */
- if ( dwError >= MIN_EACCES_RANGE && dwError <= MAX_EACCES_RANGE)
- return osl_File_E_ACCES;
- else if ( dwError >= MIN_EXEC_ERROR && dwError <= MAX_EXEC_ERROR)
- return osl_File_E_NOEXEC;
- else
- return osl_File_E_INVAL;
- }
-
- //#####################################################
- oslFileError SAL_CALL osl_openLocalRoot(
- rtl_uString *strDirectoryPath, oslDirectory *pDirectory)
- {
- rtl_uString *strSysPath = NULL;
- oslFileError error;
-
- if ( !pDirectory )
- return osl_File_E_INVAL;
+ static void* operator new(size_t n);
+ static void operator delete(void * p, size_t);
+ static SIZE_T getpagesize();
- *pDirectory = NULL;
+ sal_uInt64 getPos() const;
+ oslFileError setPos (sal_uInt64 uPos);
- error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysPath, sal_False );
+ sal_uInt64 getSize() const;
- if ( osl_File_E_None == error )
- {
- Directory_Impl *pDirImpl;
+ oslFileError readAt (
+ LONGLONG nOffset,
+ void * pBuffer,
+ DWORD nBytesRequested,
+ sal_uInt64 * pBytesRead);
- pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory( sizeof(Directory_Impl)));
- _tcscpy( pDirImpl->szDirectoryPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysPath)) );
+ oslFileError writeAt (
+ LONGLONG nOffset,
+ void const * pBuffer,
+ DWORD nBytesToWrite,
+ sal_uInt64 * pBytesWritten);
- /* Append backslash if neccessary */
+ oslFileError readFileAt (
+ LONGLONG nOffset,
+ void * pBuffer,
+ sal_uInt64 uBytesRequested,
+ sal_uInt64 * pBytesRead);
- /* @@@ToDo
- use function ensure backslash
- */
- if ( pDirImpl->szDirectoryPath[_tcslen(pDirImpl->szDirectoryPath) - 1] != L'\\' )
- _tcscat( pDirImpl->szDirectoryPath, L"\\" );
+ oslFileError writeFileAt (
+ LONGLONG nOffset,
+ void const * pBuffer,
+ sal_uInt64 uBytesToWrite,
+ sal_uInt64 * pBytesWritten);
- pDirImpl->uType = DIRECTORYTYPE_LOCALROOT;
- pDirImpl->hEnumDrives = OpenLogicalDrivesEnum();
+ oslFileError readLineAt (
+ LONGLONG nOffset,
+ sal_Sequence ** ppSequence,
+ sal_uInt64 * pBytesRead);
- /* @@@ToDo
- Use IsValidHandle(...)
- */
- if ( pDirImpl->hEnumDrives != INVALID_HANDLE_VALUE )
- {
- *pDirectory = (oslDirectory)pDirImpl;
- error = osl_File_E_None;
- }
- else
- {
- if ( pDirImpl )
- rtl_freeMemory(pDirImpl);
+ oslFileError writeSequence_Impl (
+ sal_Sequence ** ppSequence,
+ SIZE_T * pnOffset,
+ const void * pBuffer,
+ SIZE_T nBytes);
- error = MapError( GetLastError() );
- }
+ oslFileError syncFile();
- rtl_uString_release( strSysPath );
- }
- return error;
- }
-
- //#####################################################
- oslFileError SAL_CALL osl_openFileDirectory(
- rtl_uString *strDirectoryPath, oslDirectory *pDirectory)
+ /** Buffer cache / allocator.
+ */
+ class Allocator
{
- // MT: Done in osl_openDirectory!
-// rtl_uString *strSysPath = NULL;
- oslFileError error;
-
- //MT: Not done in osl_openNetworkServer, why here?
- if ( !pDirectory )
- return osl_File_E_INVAL;
-
- *pDirectory = NULL;
-
- // MT: Done in osl_openDirectory!
-// error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysPath, sal_False );
-// if ( osl_File_E_None == error )
- {
- Directory_Impl *pDirImpl;
-
- pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl)));
- _tcscpy( pDirImpl->szDirectoryPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strDirectoryPath)) );
-
- /* Append backslash if neccessary */
+ rtl_cache_type * m_cache;
+ SIZE_T m_bufsiz;
- /* @@@ToDo
- use function ensure backslash
- */
- if ( pDirImpl->szDirectoryPath[_tcslen(pDirImpl->szDirectoryPath) - 1] != L'\\' )
- _tcscat( pDirImpl->szDirectoryPath, L"\\" );
- // MT: ???
- // GetCaseCorrectPathName( pDirImpl->szDirectoryPath, pDirImpl->szDirectoryPath, sizeof(pDirImpl->szDirectoryPath) );
+ Allocator (Allocator const &);
+ Allocator & operator= (Allocator const &);
- pDirImpl->uType = DIRECTORYTYPE_FILESYSTEM;
- pDirImpl->hDirectory = OpenDirectory( pDirImpl->szDirectoryPath );
+ public:
+ static Allocator & get();
- if ( pDirImpl->hDirectory )
- {
- *pDirectory = (oslDirectory)pDirImpl;
- error = osl_File_E_None;
- }
- else
- {
- if ( pDirImpl )
- rtl_freeMemory(pDirImpl);
-
- error = MapError( GetLastError() );
- }
-
-// rtl_uString_release( strSysPath );
- }
- return error;
- }
-
- typedef struct tagDIRECTORY
- {
- HANDLE hFind;
- WIN32_FIND_DATA aFirstData;
- } DIRECTORY, *PDIRECTORY, FAR *LPDIRECTORY;
+ void allocate (sal_uInt8 ** ppBuffer, SIZE_T * pnSize);
+ void deallocate (sal_uInt8 * pBuffer);
- //#####################################################
- HANDLE WINAPI OpenDirectory(LPCTSTR lpszPath)
- {
- LPDIRECTORY pDirectory = (LPDIRECTORY)HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY));
-
- if (pDirectory)
- {
- TCHAR szFileMask[MAX_PATH];
- int nLen;
-
- _tcscpy( szFileMask, lpszPath );
- nLen = _tcslen( szFileMask );
-
- if (nLen && szFileMask[nLen-1] != '\\')
- _tcscat(szFileMask, TEXT("\\*.*"));
- else
- _tcscat(szFileMask, TEXT("*.*"));
-
- pDirectory->hFind = FindFirstFile(szFileMask, &pDirectory->aFirstData);
-
- if (!IsValidHandle(pDirectory->hFind))
- {
- if ( GetLastError() != ERROR_NO_MORE_FILES )
- {
- HeapFree(GetProcessHeap(), 0, pDirectory);
- pDirectory = NULL;
- }
- }
- }
- return (HANDLE)pDirectory;
- }
-
- //#####################################################
- BOOL WINAPI CloseDirectory(HANDLE hDirectory)
- {
- BOOL fSuccess = FALSE;
- LPDIRECTORY pDirectory = (LPDIRECTORY)hDirectory;
+ protected:
+ Allocator();
+ ~Allocator();
+ };
+};
- if (pDirectory)
- {
- if (IsValidHandle(pDirectory->hFind))
- fSuccess = FindClose(pDirectory->hFind);
+FileHandle_Impl::Allocator &
+FileHandle_Impl::Allocator::get()
+{
+ static Allocator g_aBufferAllocator;
+ return g_aBufferAllocator;
+}
- fSuccess = HeapFree(GetProcessHeap(), 0, pDirectory) && fSuccess;
- }
- else
- SetLastError(ERROR_INVALID_HANDLE);
+FileHandle_Impl::Allocator::Allocator()
+ : m_cache (0),
+ m_bufsiz (0)
+{
+ SIZE_T const pagesize = FileHandle_Impl::getpagesize();
+ m_cache = rtl_cache_create (
+ "osl_file_buffer_cache", pagesize, 0, 0, 0, 0, 0, 0, 0);
+ if (0 != m_cache)
+ m_bufsiz = pagesize;
+}
- return fSuccess;
- }
+FileHandle_Impl::Allocator::~Allocator()
+{
+ rtl_cache_destroy(m_cache), m_cache = 0;
+}
- //#####################################################
- BOOL WINAPI EnumDirectory(HANDLE hDirectory, LPWIN32_FIND_DATA pFindData)
- {
- BOOL fSuccess = FALSE;
- LPDIRECTORY pDirectory = (LPDIRECTORY)hDirectory;
+void FileHandle_Impl::Allocator::allocate (sal_uInt8 ** ppBuffer, SIZE_T * pnSize)
+{
+ OSL_PRECOND((0 != ppBuffer) && (0 != pnSize), "FileHandle_Impl::Allocator::allocate(): contract violation");
+ *ppBuffer = static_cast< sal_uInt8* >(rtl_cache_alloc(m_cache)), *pnSize = m_bufsiz;
+}
- if ( pDirectory )
- {
- BOOL fValid;
+void FileHandle_Impl::Allocator::deallocate (sal_uInt8 * pBuffer)
+{
+ if (0 != pBuffer)
+ rtl_cache_free (m_cache, pBuffer);
+}
- do
- {
- if ( pDirectory->aFirstData.cFileName[0] )
- {
- *pFindData = pDirectory->aFirstData;
- fSuccess = TRUE;
- pDirectory->aFirstData.cFileName[0] = 0;
- }
- else if ( IsValidHandle( pDirectory->hFind ) )
- fSuccess = FindNextFile( pDirectory->hFind, pFindData );
- else
- {
- fSuccess = FALSE;
- SetLastError( ERROR_NO_MORE_FILES );
- }
+FileHandle_Impl::FileHandle_Impl(HANDLE hFile)
+ : m_hFile (hFile),
+ m_state (STATE_READABLE | STATE_WRITEABLE),
+ m_size (0),
+ m_offset (0),
+ m_filepos (0),
+ m_bufptr (-1),
+ m_buflen (0),
+ m_bufsiz (0),
+ m_buffer (0)
+{
+ Allocator::get().allocate (&m_buffer, &m_bufsiz);
+ if (m_buffer != 0)
+ memset (m_buffer, 0, m_bufsiz);
+}
- fValid = fSuccess && _tcscmp( TEXT("."), pFindData->cFileName ) != 0 && _tcscmp( TEXT(".."), pFindData->cFileName ) != 0;
+FileHandle_Impl::~FileHandle_Impl()
+{
+ Allocator::get().deallocate (m_buffer), m_buffer = 0;
+}
- } while( fSuccess && !fValid );
- }
- else
- SetLastError( ERROR_INVALID_HANDLE );
+void * FileHandle_Impl::operator new(size_t n)
+{
+ return rtl_allocateMemory(n);
+}
- return fSuccess;
- }
+void FileHandle_Impl::operator delete(void * p, size_t)
+{
+ rtl_freeMemory(p);
+}
- //#####################################################
- oslFileError SAL_CALL osl_openNetworkServer(rtl_uString *strSysDirPath, oslDirectory *pDirectory)
- {
- NETRESOURCEW aNetResource;
- HANDLE hEnum;
- DWORD dwError;
+SIZE_T FileHandle_Impl::getpagesize()
+{
+ SYSTEM_INFO info;
+ ::GetSystemInfo (&info);
+ return sal::static_int_cast< SIZE_T >(info.dwPageSize);
+}
- ZeroMemory( &aNetResource, sizeof(aNetResource) );
+sal_uInt64 FileHandle_Impl::getPos() const
+{
+ return sal::static_int_cast< sal_uInt64 >(m_filepos);
+}
- aNetResource.lpRemoteName = reinterpret_cast<LPWSTR>(strSysDirPath->buffer);
+oslFileError FileHandle_Impl::setPos (sal_uInt64 uPos)
+{
+ m_filepos = sal::static_int_cast< LONGLONG >(uPos);
+ return osl_File_E_None;
+}
- dwError = WNetOpenEnumW(
- RESOURCE_GLOBALNET,
- RESOURCETYPE_DISK,
- RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER,
- &aNetResource,
- &hEnum );
+sal_uInt64 FileHandle_Impl::getSize() const
+{
+ LONGLONG bufend = std::max((LONGLONG)(0), m_bufptr) + m_buflen;
+ return std::max(m_size, sal::static_int_cast< sal_uInt64 >(bufend));
+}
- if ( ERROR_SUCCESS == dwError )
- {
- Directory_Impl *pDirImpl;
+oslFileError FileHandle_Impl::readAt (
+ LONGLONG nOffset,
+ void * pBuffer,
+ DWORD nBytesRequested,
+ sal_uInt64 * pBytesRead)
+{
+ OSL_PRECOND(m_state & STATE_SEEKABLE, "FileHandle_Impl::readAt(): not seekable");
+ if (!(m_state & STATE_SEEKABLE))
+ return osl_File_E_SPIPE;
- pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl)));
- pDirImpl->uType = DIRECTORYTYPE_NETROOT;
- pDirImpl->hDirectory = hEnum;
- *pDirectory = (oslDirectory)pDirImpl;
- }
- return MapError( dwError );
- }
+ OSL_PRECOND(m_state & STATE_READABLE, "FileHandle_Impl::readAt(): not readable");
+ if (!(m_state & STATE_READABLE))
+ return osl_File_E_BADF;
- //#####################################################
- oslFileError SAL_CALL osl_getNextNetResource(
- oslDirectory Directory,
- oslDirectoryItem *pItem,
- sal_uInt32 uHint )
+ if (nOffset != m_offset)
{
- Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
- DirectoryItem_Impl *pItemImpl = NULL;
- BYTE buffer[16384];
- LPNETRESOURCEW lpNetResource = (LPNETRESOURCEW)buffer;
- DWORD dwError, dwCount, dwBufSize;
-
- uHint = uHint; /* to get no warning */
-
- if ( !pItem )
- return osl_File_E_INVAL;
-
- *pItem = NULL;
-
- if ( !pDirImpl )
- return osl_File_E_INVAL;
-
- dwCount = 1;
- dwBufSize = sizeof(buffer);
- dwError = WNetEnumResource( pDirImpl->hDirectory, &dwCount, lpNetResource, &dwBufSize );
-
- switch ( dwError )
- {
- case NO_ERROR:
- case ERROR_MORE_DATA:
- {
- pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
- if ( !pItemImpl )
- return osl_File_E_NOMEM;
-
- ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
- pItemImpl->uType = DIRECTORYITEM_DRIVE;
- osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
-
- wcscpy( pItemImpl->cDriveString, lpNetResource->lpRemoteName );
-
- *pItem = pItemImpl;
- }
- return osl_File_E_None;
- case ERROR_NO_MORE_ITEMS:
- return osl_File_E_NOENT;
- default:
- return MapError( dwError );
- }
+ LARGE_INTEGER liOffset; liOffset.QuadPart = nOffset;
+ if (!::SetFilePointerEx(m_hFile, liOffset, 0, FILE_BEGIN))
+ return oslTranslateFileError( GetLastError() );
+ m_offset = nOffset;
}
- //#####################################################
- oslFileError SAL_CALL osl_getNextDrive(
- oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint )
- {
- Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
- DirectoryItem_Impl *pItemImpl = NULL;
- BOOL fSuccess;
-
- uHint = uHint; /* avoid warnings */
-
- if ( !pItem )
- return osl_File_E_INVAL;
-
- *pItem = NULL;
-
- if ( !pDirImpl )
- return osl_File_E_INVAL;
+ DWORD dwDone = 0;
+ if (!::ReadFile(m_hFile, pBuffer, nBytesRequested, &dwDone, 0))
+ return oslTranslateFileError( GetLastError() );
+ m_offset += dwDone;
- pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
- if ( !pItemImpl )
- return osl_File_E_NOMEM;
+ *pBytesRead = dwDone;
+ return osl_File_E_None;
+}
+oslFileError FileHandle_Impl::writeAt (
+ LONGLONG nOffset,
+ void const * pBuffer,
+ DWORD nBytesToWrite,
+ sal_uInt64 * pBytesWritten)
+{
+ OSL_PRECOND(m_state & STATE_SEEKABLE, "FileHandle_Impl::writeAt(): not seekable");
+ if (!(m_state & STATE_SEEKABLE))
+ return osl_File_E_SPIPE;
- ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
- pItemImpl->uType = DIRECTORYITEM_DRIVE;
- osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
- fSuccess = EnumLogicalDrives( pDirImpl->hEnumDrives, pItemImpl->cDriveString );
+ OSL_PRECOND(m_state & STATE_WRITEABLE, "FileHandle_Impl::writeAt(): not writeable");
+ if (!(m_state & STATE_WRITEABLE))
+ return osl_File_E_BADF;
- if ( fSuccess )
- {
- *pItem = pItemImpl;
- return osl_File_E_None;
- }
- else
- {
- rtl_freeMemory( pItemImpl );
- return MapError( GetLastError() );
- }
- }
-
- //#####################################################
- oslFileError SAL_CALL osl_getNextFileItem(
- oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint)
+ if (nOffset != m_offset)
{
- Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
- DirectoryItem_Impl *pItemImpl = NULL;
- BOOL fFound;
-
- uHint = uHint; /* avoid warnings */
-
- if ( !pItem )
- return osl_File_E_INVAL;
-
- *pItem = NULL;
-
- if ( !pDirImpl )
- return osl_File_E_INVAL;
-
- pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
- if ( !pItemImpl )
- return osl_File_E_NOMEM;
-
- memset( pItemImpl, 0, sizeof(DirectoryItem_Impl) );
- fFound = EnumDirectory( pDirImpl->hDirectory, &pItemImpl->FindData );
-
- if ( fFound )
- {
- pItemImpl->uType = DIRECTORYITEM_FILE;
- pItemImpl->nRefCount = 1;
- _tcscpy( pItemImpl->szFullPath, pDirImpl->szDirectoryPath );
- _tcscat( pItemImpl->szFullPath, pItemImpl->FindData.cFileName );
- pItemImpl->bFullPathNormalized = FALSE;
- *pItem = (oslDirectoryItem)pItemImpl;
- return osl_File_E_None;
- }
- else
- {
- rtl_freeMemory( pItemImpl );
- return MapError( GetLastError() );
- }
+ LARGE_INTEGER liOffset; liOffset.QuadPart = nOffset;
+ if (!::SetFilePointerEx (m_hFile, liOffset, 0, FILE_BEGIN))
+ return oslTranslateFileError( GetLastError() );
+ m_offset = nOffset;
}
- //#####################################################
- oslFileError SAL_CALL osl_getDriveInfo(
- oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask)
- {
- DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
- TCHAR cDrive[3] = TEXT("A:");
- TCHAR cRoot[4] = TEXT("A:\\");
-
- if ( !pItemImpl )
- return osl_File_E_INVAL;
-
- pStatus->uValidFields = 0;
-
- cDrive[0] = pItemImpl->cDriveString[0];
- cRoot[0] = pItemImpl->cDriveString[0];
-
- if ( uFieldMask & osl_FileStatus_Mask_FileName )
- {
- if ( pItemImpl->cDriveString[0] == '\\' &&
- pItemImpl->cDriveString[1] == '\\' )
- {
- LPCWSTR lpFirstBkSlash = wcschr( &pItemImpl->cDriveString[2], '\\' );
-
- if ( lpFirstBkSlash && lpFirstBkSlash[1] )
- {
- LPCWSTR lpLastBkSlash = wcschr( &lpFirstBkSlash[1], '\\' );
-
- if ( lpLastBkSlash )
- rtl_uString_newFromStr_WithLength( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(&lpFirstBkSlash[1]), lpLastBkSlash - lpFirstBkSlash - 1 );
- else
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(&lpFirstBkSlash[1]) );
- pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
- }
- }
- else switch ( GetDriveType( cRoot ) )
- {
- case DRIVE_REMOTE:
- {
- TCHAR szBuffer[1024];
- DWORD dwBufsize = ELEMENTS_OF_ARRAY(szBuffer);
- DWORD dwResult = WNetGetConnection( cDrive, szBuffer, &dwBufsize );
-
- if ( NO_ERROR == dwResult )
- {
- TCHAR szFileName[ELEMENTS_OF_ARRAY(szBuffer) + 16];
-
- swprintf( szFileName, L"%s [%s]", cDrive, szBuffer );
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(szFileName) );
- }
- else
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cDrive) );
- }
- pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
- break;
- case DRIVE_FIXED:
- {
- TCHAR szVolumeNameBuffer[1024];
-
- if ( GetVolumeInformation( cRoot, szVolumeNameBuffer, ELEMENTS_OF_ARRAY(szVolumeNameBuffer), NULL, NULL, NULL, NULL, 0 ) )
- {
- TCHAR szFileName[ELEMENTS_OF_ARRAY(szVolumeNameBuffer) + 16];
-
- swprintf( szFileName, L"%s [%s]", cDrive, szVolumeNameBuffer );
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(szFileName) );
- }
- else
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cDrive) );
- }
- pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
- break;
- case DRIVE_CDROM:
- case DRIVE_REMOVABLE:
- pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cRoot) );
- break;
- case DRIVE_UNKNOWN:
- default:
- break;
- }
- }
+ DWORD dwDone = 0;
+ if (!::WriteFile(m_hFile, pBuffer, nBytesToWrite, &dwDone, 0))
+ return oslTranslateFileError( GetLastError() );
+ m_offset += dwDone;
- pStatus->eType = osl_File_Type_Volume;
- pStatus->uValidFields |= osl_FileStatus_Mask_Type;
+ m_size = std::max(m_size, sal::static_int_cast< sal_uInt64 >(m_offset));
- if ( uFieldMask & osl_FileStatus_Mask_FileURL )
- {
- rtl_uString *ustrSystemPath = NULL;
+ *pBytesWritten = dwDone;
+ return osl_File_E_None;
+}
- rtl_uString_newFromStr( &ustrSystemPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->cDriveString) );
- osl_getFileURLFromSystemPath( ustrSystemPath, &pStatus->ustrFileURL );
- rtl_uString_release( ustrSystemPath );
- pStatus->uValidFields |= osl_FileStatus_Mask_FileURL;
- }
- return osl_File_E_None;
- }
+oslFileError FileHandle_Impl::readFileAt (
+ LONGLONG nOffset,
+ void * pBuffer,
+ sal_uInt64 uBytesRequested,
+ sal_uInt64 * pBytesRead)
+{
+ static sal_uInt64 const g_limit_dword = std::numeric_limits< DWORD >::max();
+ if (g_limit_dword < uBytesRequested)
+ return osl_File_E_OVERFLOW;
+ DWORD nBytesRequested = sal::static_int_cast< DWORD >(uBytesRequested);
- //#####################################################
- oslFileError SAL_CALL osl_getServerInfo(
- oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask )
+ if (0 == (m_state & STATE_SEEKABLE))
{
- DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
-
- if ( !pItemImpl )
- return osl_File_E_INVAL;
-
- pStatus->uValidFields = 0;
-
- // pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
-
- // if ( _tcscmp( pItemImpl->FindData.cFileName, TEXT(".") ) == 0 )
- // rtl_uString_newFromAscii( &pStatus->ustrFileName, "/" );
- // else
- // rtl_uString_newFromStr( &pStatus->ustrFileName, pItemImpl->FindData.cFileName );
-
- pStatus->eType = osl_File_Type_Directory;
- pStatus->uValidFields |= osl_FileStatus_Mask_Type;
-
- if ( uFieldMask & osl_FileStatus_Mask_FileURL )
- {
- rtl_uString *ustrSystemPath = NULL;
-
- rtl_uString_newFromStr( &ustrSystemPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) );
- osl_getFileURLFromSystemPath( ustrSystemPath, &pStatus->ustrFileURL );
- rtl_uString_release( ustrSystemPath );
- pStatus->uValidFields |= osl_FileStatus_Mask_FileURL;
- }
+ // not seekable (pipe)
+ DWORD dwDone = 0;
+ if (!::ReadFile(m_hFile, pBuffer, nBytesRequested, &dwDone, 0))
+ return oslTranslateFileError( GetLastError() );
+ *pBytesRead = dwDone;
return osl_File_E_None;
}
-
- typedef struct tagDRIVEENUM {
- LPCTSTR lpIdent;
- TCHAR cBuffer[/*('Z' - 'A' + 1) * sizeof("A:\\") + 1*/256];
- LPCTSTR lpCurrent;
- } DRIVEENUM, * PDRIVEENUM, FAR * LPDRIVEENUM;
-
- //#####################################################
- HANDLE WINAPI OpenLogicalDrivesEnum(void)
+ else if (0 == m_buffer)
{
- LPDRIVEENUM pEnum = NULL;
-
- pEnum = (LPDRIVEENUM)HeapAlloc( GetProcessHeap(), 0, sizeof(DRIVEENUM) );
-
- if ( pEnum )
- {
- DWORD dwNumCopied = GetLogicalDriveStrings( (sizeof(pEnum->cBuffer) - 1) / sizeof(TCHAR), pEnum->cBuffer );
-
- if ( dwNumCopied && dwNumCopied < sizeof(pEnum->cBuffer) / sizeof(TCHAR) )
- {
- pEnum->lpCurrent = pEnum->cBuffer;
- pEnum->lpIdent = L"tagDRIVEENUM";
- }
- else
- {
- HeapFree( GetProcessHeap(), 0, pEnum );
- pEnum = NULL;
- }
- }
- return pEnum ? (HANDLE)pEnum : INVALID_HANDLE_VALUE;
+ // not buffered
+ return readAt (nOffset, pBuffer, nBytesRequested, pBytesRead);
}
-
- //#####################################################
- BOOL WINAPI EnumLogicalDrives(HANDLE hEnum, LPTSTR lpBuffer)
+ else
{
- BOOL fSuccess = FALSE;
- LPDRIVEENUM pEnum = (LPDRIVEENUM)hEnum;
-
- if ( pEnum )
+ sal_uInt8 * buffer = static_cast< sal_uInt8* >(pBuffer);
+ for (*pBytesRead = 0; nBytesRequested > 0; )
{
- int nLen = _tcslen( pEnum->lpCurrent );
+ LONGLONG const bufptr = (nOffset / m_bufsiz) * m_bufsiz;
+ SIZE_T const bufpos = (nOffset % m_bufsiz);
- if ( nLen )
+ if (bufptr != m_bufptr)
{
- CopyMemory( lpBuffer, pEnum->lpCurrent, (nLen + 1) * sizeof(TCHAR) );
- pEnum->lpCurrent += nLen + 1;
- fSuccess = TRUE;
- }
- else
- SetLastError( ERROR_NO_MORE_FILES );
- }
- else
- SetLastError( ERROR_INVALID_HANDLE );
-
- return fSuccess;
- }
+ // flush current buffer
+ oslFileError result = syncFile();
+ if (result != osl_File_E_None)
+ return (result);
- //#####################################################
- BOOL WINAPI CloseLogicalDrivesEnum(HANDLE hEnum)
- {
- BOOL fSuccess = FALSE;
- LPDRIVEENUM pEnum = (LPDRIVEENUM)hEnum;
-
- if ( pEnum )
- {
- HeapFree( GetProcessHeap(), 0, pEnum );
- fSuccess = TRUE;
- }
- else
- SetLastError( ERROR_INVALID_HANDLE );
-
- return fSuccess;
- }
-
- //#####################################################
- //Undocumented in SHELL32.DLL ordinal 35
- BOOL WINAPI PathRemoveFileSpec(LPTSTR lpPath)
- {
- BOOL fSuccess = FALSE; // Assume failure
- LPTSTR lpLastBkSlash = _tcsrchr( lpPath, '\\' );
- LPTSTR lpLastSlash = _tcsrchr( lpPath, '/' );
- LPTSTR lpLastDelimiter = lpLastSlash > lpLastBkSlash ? lpLastSlash : lpLastBkSlash;
-
- if ( lpLastDelimiter )
- {
- if ( 0 == *(lpLastDelimiter + 1) )
- {
- if ( lpLastDelimiter > lpPath && *(lpLastDelimiter - 1) != ':' )
+ if (nBytesRequested >= m_bufsiz)
{
- *lpLastDelimiter = 0;
- fSuccess = TRUE;
+ // buffer too small, read through from file
+ sal_uInt64 uDone = 0;
+ result = readAt (nOffset, &(buffer[*pBytesRead]), nBytesRequested, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
+
+ nBytesRequested -= sal::static_int_cast< DWORD >(uDone), *pBytesRead += uDone;
+ return osl_File_E_None;
}
- }
- else
- {
- *(++lpLastDelimiter) = 0;
- fSuccess = TRUE;
- }
- }
- return fSuccess;
- }
-
- //#####################################################
- // Undocumented in SHELL32.DLL ordinal 32
- LPTSTR WINAPI PathAddBackslash(LPTSTR lpPath)
- {
- LPTSTR lpEndPath = NULL;
-
- if ( lpPath )
- {
- int nLen = _tcslen(lpPath);
- if ( !nLen || lpPath[nLen-1] != '\\' && lpPath[nLen-1] != '/' && nLen < MAX_PATH - 1 )
- {
- lpEndPath = lpPath + nLen;
- *lpEndPath++ = '\\';
- *lpEndPath = 0;
+ // update buffer (pointer)
+ sal_uInt64 uDone = 0;
+ result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
+ m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone);
}
- }
- return lpEndPath;
- }
-
-#if 1
- //#####################################################
- // Same as GetLongPathName but also 95/NT4
- DWORD WINAPI GetCaseCorrectPathNameEx(
- LPCTSTR lpszShortPath, // file name
- LPTSTR lpszLongPath, // path buffer
- DWORD cchBuffer, // size of path buffer
- DWORD nSkipLevels
- )
- {
-// log file doesn't work, because initialization of rtl log init() calls this method...
-// RTL_LOGFILE_TRACE1( "SAL: GetCaseCorrectPathNameEx: %s (Skip:%n)", lpszShortPath,nSkipLevels );
-
- TCHAR szPath[MAX_PATH];
- BOOL fSuccess;
-
- cchBuffer = cchBuffer; /* avoid warnings */
-
- _tcscpy( szPath, lpszShortPath );
-
- fSuccess = PathRemoveFileSpec( szPath );
-
- if ( fSuccess )
- {
- int nLen = _tcslen( szPath );
- LPCTSTR lpszFileSpec = lpszShortPath + nLen;
- BOOL bSkipThis;
-
- if ( 0 == _tcscmp( lpszFileSpec, TEXT("..") ) )
- {
- bSkipThis = TRUE;
- nSkipLevels += 1;
- }
- else if (
- 0 == _tcscmp( lpszFileSpec, TEXT(".") ) ||
- 0 == _tcscmp( lpszFileSpec, TEXT("\\") ) ||
- 0 == _tcscmp( lpszFileSpec, TEXT("/") )
- )
+ if (bufpos >= m_buflen)
{
- bSkipThis = TRUE;
- }
- else if ( nSkipLevels )
- {
- bSkipThis = TRUE;
- nSkipLevels--;
- }
- else
- bSkipThis = FALSE;
-
- GetCaseCorrectPathNameEx( szPath, szPath, MAX_PATH, nSkipLevels );
-
- PathAddBackslash( szPath );
-
- /* Analyze parent if not only a trailing backslash was cutted but a real file spec */
- if ( !bSkipThis )
- {
- WIN32_FIND_DATA aFindFileData;
- HANDLE hFind = FindFirstFile( lpszShortPath, &aFindFileData );
-
- if ( IsValidHandle(hFind) )
- {
- _tcscat( szPath, aFindFileData.cFileName[0] ? aFindFileData.cFileName : aFindFileData.cAlternateFileName );
-
- FindClose( hFind );
- }
- else
- return 0;
+ // end of file
+ return osl_File_E_None;
}
- }
- else
- {
- /* File specification can't be removed therefore the short path is either a drive
- or a network share. If still levels to skip are left, the path specification
- tries to travel below the file system root */
- if ( nSkipLevels )
- return 0;
-
- _tcsupr( szPath );
- }
-
- _tcscpy( lpszLongPath, szPath );
-
- return _tcslen( lpszLongPath );
- }
-#endif
-#if 0
- inline size_t wcstoupper( LPWSTR lpStr )
- {
- size_t nLen = wcslen( lpStr );
-
- for ( LPWSTR p = lpStr; p < lpStr + nLen; p++ )
- {
- *p = towupper(*p);
+ SIZE_T const bytes = std::min(m_buflen - bufpos, nBytesRequested);
+ memcpy (&(buffer[*pBytesRead]), &(m_buffer[bufpos]), bytes);
+ nBytesRequested -= bytes, *pBytesRead += bytes, nOffset += bytes;
}
-
- return nLen;
- }
-
-#endif
-
- //#####################################################
- DWORD WINAPI GetCaseCorrectPathName(
- LPCTSTR lpszShortPath, // file name
- LPTSTR lpszLongPath, // path buffer
- DWORD cchBuffer // size of path buffer
- )
-#if 0
- {
- /* Special handling for "\\.\" as system root */
- if ( lpszShortPath && 0 == wcscmp( lpszShortPath, WSTR_SYSTEM_ROOT_PATH ) )
- {
- if ( cchBuffer >= ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) )
- {
- wcscpy( lpszLongPath, WSTR_SYSTEM_ROOT_PATH );
- return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1;
- }
- else
- return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH);
- }
- else
- {
- DWORD nSrcLen = wcslen( lpszShortPath );
-
- if ( cchBuffer > nSrcLen )
- {
- wcscpy( lpszLongPath, lpszShortPath );
- wcstoupper( lpszLongPath );
- }
- else
- nSrcLen++;
-
- return nSrcLen;
- }
- }
-#else
- {
- /* Special handling for "\\.\" as system root */
- if ( lpszShortPath && 0 == wcscmp( lpszShortPath, WSTR_SYSTEM_ROOT_PATH ) )
- {
- if ( cchBuffer >= ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) )
- {
- wcscpy( lpszLongPath, WSTR_SYSTEM_ROOT_PATH );
- return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1;
- }
- else
- return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1;
- }
- else
- return GetCaseCorrectPathNameEx( lpszShortPath, lpszLongPath, cchBuffer, 0 );
+ return osl_File_E_None;
}
+}
-#endif
-
- //#####################################################
- #define CHARSET_SEPARATOR TEXT("\\/")
-
- BOOL WINAPI IsValidFilePathComponent(
- LPCTSTR lpComponent, LPCTSTR *lppComponentEnd, DWORD dwFlags)
- {
- LPCTSTR lpComponentEnd = NULL;
- LPCTSTR lpCurrent = lpComponent;
- BOOL fValid = TRUE; /* Assume success */
- TCHAR cLast = 0;
-
- /* Path component length must not exceed MAX_PATH */
-
- while ( !lpComponentEnd && lpCurrent && lpCurrent - lpComponent < MAX_PATH )
- {
- switch ( *lpCurrent )
- {
- /* Both backslash and slash determine the end of a path component */
- case '\0':
- case '/':
- case '\\':
- switch ( cLast )
- {
- /* Component must not end with '.' or blank and can't be empty */
-
- case '.':
- if ( dwFlags & VALIDATEPATH_ALLOW_ELLIPSE )
- {
- if ( 1 == lpCurrent - lpComponent )
- {
- /* Current directory is O.K. */
- lpComponentEnd = lpCurrent;
- break;
- }
- else if ( 2 == lpCurrent - lpComponent && '.' == *lpComponent )
- {
- /* Parent directory is O.K. */
- lpComponentEnd = lpCurrent;
- break;
- }
- }
- case 0:
- case ' ':
- lpComponentEnd = lpCurrent - 1;
- fValid = FALSE;
- break;
- default:
- lpComponentEnd = lpCurrent;
- break;
- }
- break;
- /* '?' and '*' are valid wildcards but not valid file name characters */
- case '?':
- case '*':
- if ( dwFlags & VALIDATEPATH_ALLOW_WILDCARDS )
- break;
- /* The following characters are reserved */
- case '<':
- case '>':
- case '\"':
- case '|':
- case ':':
- lpComponentEnd = lpCurrent;
- fValid = FALSE;
- break;
- default:
- /* Characters below ASCII 32 are not allowed */
- if ( *lpCurrent < ' ' )
- {
- lpComponentEnd = lpCurrent;
- fValid = FALSE;
- }
- break;
- }
- cLast = *lpCurrent++;
- }
-
- /* If we don't reached the end of the component the length of the component was to long
- ( See condition of while loop ) */
- if ( !lpComponentEnd )
- {
- fValid = FALSE;
- lpComponentEnd = lpCurrent;
- }
-
- /* Test wether the component specifies a device name what is not allowed */
-
- // MT: PERFORMANCE:
- // This is very expensive. A lot of calls to _tcsicmp.
- // in SRC6870m71 67.000 calls of this method while empty office start result into more than 1.500.00 calls of _tcsicmp!
- // Possible optimizations
- // - Array should be const static
- // - Sorted array, use binary search
- // - More intelligent check for com1-9, lpt1-9
- // Maybe make szComponent upper case, don't search case intensitive
- // Talked to HRO: Could be removed. Shouldn't be used in OOo, and if used for something like a filename, it will lead to an error anyway.
- /*
- if ( fValid )
- {
- LPCTSTR alpDeviceNames[] =
- {
- TEXT("CON"),
- TEXT("PRN"),
- TEXT("AUX"),
- TEXT("CLOCK$"),
- TEXT("NUL"),
- TEXT("LPT1"),
- TEXT("LPT2"),
- TEXT("LPT3"),
- TEXT("LPT4"),
- TEXT("LPT5"),
- TEXT("LPT6"),
- TEXT("LPT7"),
- TEXT("LPT8"),
- TEXT("LPT9"),
- TEXT("COM1"),
- TEXT("COM2"),
- TEXT("COM3"),
- TEXT("COM4"),
- TEXT("COM5"),
- TEXT("COM6"),
- TEXT("COM7"),
- TEXT("COM8"),
- TEXT("COM9")
- };
-
- TCHAR szComponent[MAX_PATH];
- int nComponentLength;
- LPCTSTR lpDot;
- int i;
-
- // A device name with an extension is also invalid
- lpDot = _tcschr( lpComponent, '.' );
-
- if ( !lpDot || lpDot > lpComponentEnd )
- nComponentLength = lpComponentEnd - lpComponent;
- else
- nComponentLength = lpDot - lpComponent;
-
- _tcsncpy( szComponent, lpComponent, nComponentLength );
- szComponent[nComponentLength] = 0;
-
- for ( i = 0; i < sizeof( alpDeviceNames ) / sizeof(LPCTSTR); i++ )
- {
- if ( 0 == _tcsicmp( szComponent, alpDeviceNames[i] ) )
- {
- lpComponentEnd = lpComponent;
- fValid = FALSE;
- break;
- }
- }
- }
- */
-
- if ( fValid )
- {
- // Empty components are not allowed
- if ( lpComponentEnd - lpComponent < 1 )
- fValid = FALSE;
-
- // If we reached the end of the string NULL is returned
- else if ( !*lpComponentEnd )
- lpComponentEnd = NULL;
-
- }
-
- if ( lppComponentEnd )
- *lppComponentEnd = lpComponentEnd;
-
- return fValid;
- }
+oslFileError FileHandle_Impl::writeFileAt (
+ LONGLONG nOffset,
+ void const * pBuffer,
+ sal_uInt64 uBytesToWrite,
+ sal_uInt64 * pBytesWritten)
+{
+ static sal_uInt64 const g_limit_dword = std::numeric_limits< DWORD >::max();
+ if (g_limit_dword < uBytesToWrite)
+ return osl_File_E_OVERFLOW;
+ DWORD nBytesToWrite = sal::static_int_cast< DWORD >(uBytesToWrite);
- //#####################################################
- DWORD WINAPI IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_uString **corrected)
+ if (0 == (m_state & STATE_SEEKABLE))
{
- LPCTSTR lpszPath = reinterpret_cast< LPCTSTR >(path->buffer);
- LPCTSTR lpComponent;
- BOOL fValid = TRUE;
- DWORD dwPathType = PATHTYPE_ERROR;
-
- if ( dwFlags & VALIDATEPATH_ALLOW_RELATIVE )
- dwFlags |= VALIDATEPATH_ALLOW_ELLIPSE;
-
- if ( !lpszPath )
- {
- fValid = FALSE;
- lpComponent = lpszPath;
- }
-
- /* Test for UNC path notation */
- if ( 2 == _tcsspn( lpszPath, CHARSET_SEPARATOR ) )
- {
- /* Place the pointer behind the leading to backslashes */
-
- lpComponent = lpszPath + 2;
-
- fValid = IsValidFilePathComponent( lpComponent, &lpComponent, VALIDATEPATH_ALLOW_ELLIPSE );
-
- /* So far we have a valid servername. Now let's see if we also have a network resource */
-
- dwPathType = PATHTYPE_ABSOLUTE_UNC;
-
- if ( fValid )
- {
- if ( lpComponent && !*++lpComponent )
- lpComponent = NULL;
-
- if ( !lpComponent )
- {
- #if 0
- /* We only have a Server specification what is invalid */
-
- lpComponent = lpszPath;
- fValid = FALSE;
- #else
- dwPathType |= PATHTYPE_IS_SERVER;
- #endif
- }
- else
- {
- /* Now test the network resource */
-
- fValid = IsValidFilePathComponent( lpComponent, &lpComponent, 0 );
-
- /* If we now reached the end of the path, everything is O.K. */
-
-
- if ( fValid && (!lpComponent || lpComponent && !*++lpComponent ) )
- {
- lpComponent = NULL;
- dwPathType |= PATHTYPE_IS_VOLUME;
- }
- }
- }
- }
-
- /* Local path verification. Must start with <drive>: */
- else if ( _istalpha( lpszPath[0] ) && ':' == lpszPath[1] )
- {
- /* Place pointer behind correct drive specification */
-
- lpComponent = lpszPath + 2;
-
- if ( 1 == _tcsspn( lpComponent, CHARSET_SEPARATOR ) )
- lpComponent++;
- else if ( *lpComponent )
- fValid = FALSE;
-
- dwPathType = PATHTYPE_ABSOLUTE_LOCAL;
-
- /* Now we are behind the backslash or it was a simple drive without backslash */
-
- if ( fValid && !*lpComponent )
- {
- lpComponent = NULL;
- dwPathType |= PATHTYPE_IS_VOLUME;
- }
- }
-
- /* Can be a relative path */
- else if ( dwFlags & VALIDATEPATH_ALLOW_RELATIVE )
- {
- lpComponent = lpszPath;
-
- /* Relative path can start with a backslash */
-
- if ( 1 == _tcsspn( lpComponent, CHARSET_SEPARATOR ) )
- {
- lpComponent++;
- if ( !*lpComponent )
- lpComponent = NULL;
- }
-
- dwPathType = PATHTYPE_RELATIVE;
- }
-
- /* Anything else is an error */
- else
- {
- fValid = FALSE;
- lpComponent = lpszPath;
- }
-
- /* Now validate each component of the path */
- while ( fValid && lpComponent )
- {
- // Correct path by merging consecutive slashes:
- if (*lpComponent == '\\' && corrected != NULL) {
- sal_Int32 i = lpComponent - lpszPath;
- rtl_uString_newReplaceStrAt(corrected, path, i, 1, NULL);
- //TODO: handle out-of-memory
- lpszPath = reinterpret_cast< LPCTSTR >((*corrected)->buffer);
- lpComponent = lpszPath + i;
- }
-
- fValid = IsValidFilePathComponent( lpComponent, &lpComponent, dwFlags );
-
- if ( fValid && lpComponent )
- {
- lpComponent++;
-
- /* If the string behind the backslash is empty, we've done */
-
- if ( !*lpComponent )
- lpComponent = NULL;
- }
- }
-
- if ( fValid && _tcslen( lpszPath ) >= MAX_PATH )
- {
- fValid = FALSE;
- lpComponent = lpszPath + MAX_PATH;
- }
-
- if ( lppError )
- *lppError = lpComponent;
-
- return fValid ? dwPathType : PATHTYPE_ERROR;
+ // not seekable (pipe)
+ DWORD dwDone = 0;
+ if (!::WriteFile(m_hFile, pBuffer, nBytesToWrite, &dwDone, 0))
+ return oslTranslateFileError( GetLastError() );
+ *pBytesWritten = dwDone;
+ return osl_File_E_None;
}
-
- //#####################################################
- bool is_floppy_drive(const rtl::OUString& path);
-
- //#####################################################
- struct Component
- {
- Component() :
- begin_(0), end_(0)
- {}
-
- bool isPresent() const
- { return (static_cast<sal_Int32>(end_ - begin_) > 0); }
-
- const sal_Unicode* begin_;
- const sal_Unicode* end_;
- };
-
- //#####################################################
- struct UNCComponents
- {
- Component server_;
- Component share_;
- Component resource_;
- };
-
- //#####################################################
- const wchar_t UNC_PREFIX[] = L"\\\\";
- const wchar_t BACKSLASH = '\\';
- const wchar_t SLASH = '/';
-
- bool is_UNC_path(const sal_Unicode* path)
- { return (0 == wcsncmp(UNC_PREFIX, reinterpret_cast<LPCWSTR>(path), ELEMENTS_OF_ARRAY(UNC_PREFIX) - 1)); }
-
- //#####################################################
- bool is_UNC_path(const rtl::OUString& path)
- { return is_UNC_path(path.getStr()); }
-
- //#####################################################
- void parse_UNC_path(const sal_Unicode* path, UNCComponents* puncc)
+ else if (0 == m_buffer)
{
- OSL_PRECOND(is_UNC_path(path), "Precondition violated: No UNC path");
- OSL_PRECOND(rtl_ustr_indexOfChar(path, SLASH) != -1, "Path must not contain slashes");
-
- const sal_Unicode* pend = path + rtl_ustr_getLength(path);
- const sal_Unicode* ppos = path + 2;
-
- puncc->server_.begin_ = ppos;
- while ((ppos < pend) && (*ppos != BACKSLASH))
- ppos++;
-
- puncc->server_.end_ = ppos;
-
- if (BACKSLASH == *ppos)
- {
- puncc->share_.begin_ = ++ppos;
- while ((ppos < pend) && (*ppos != BACKSLASH))
- ppos++;
-
- puncc->share_.end_ = ppos;
-
- if (BACKSLASH == *ppos)
- {
- puncc->resource_.begin_ = ++ppos;
- while (ppos < pend)
- ppos++;
-
- puncc->resource_.end_ = ppos;
- }
- }
-
- OSL_POSTCOND(puncc->server_.isPresent() && puncc->share_.isPresent(), \
- "Postcondition violated: Invalid UNC path detected");
+ // not buffered
+ return writeAt(nOffset, pBuffer, nBytesToWrite, pBytesWritten);
}
-
- //#####################################################
- void parse_UNC_path(const rtl::OUString& path, UNCComponents* puncc)
- { parse_UNC_path(path.getStr(), puncc); }
-
- //#####################################################
- bool is_volume_mount_point(const rtl::OUString& path)
+ else
{
- rtl::OUString p(path);
- osl::systemPathRemoveSeparator(p);
-
- bool is_volume_root = false;
-
- if (!is_floppy_drive(p))
+ sal_uInt8 const * buffer = static_cast< sal_uInt8 const* >(pBuffer);
+ for (*pBytesWritten = 0; nBytesToWrite > 0; )
{
- DWORD fattr = GetFileAttributes(reinterpret_cast<LPCTSTR>(p.getStr()));
-
- if ((INVALID_FILE_ATTRIBUTES != fattr) &&
- (FILE_ATTRIBUTE_REPARSE_POINT & fattr))
+ LONGLONG const bufptr = (nOffset / m_bufsiz) * m_bufsiz;
+ SIZE_T const bufpos = (nOffset % m_bufsiz);
+ if (bufptr != m_bufptr)
{
- WIN32_FIND_DATA find_data;
- HANDLE h_find = FindFirstFile(reinterpret_cast<LPCTSTR>(p.getStr()), &find_data);
+ // flush current buffer
+ oslFileError result = syncFile();
+ if (result != osl_File_E_None)
+ return (result);
- if (IsValidHandle(h_find) &&
- (FILE_ATTRIBUTE_REPARSE_POINT & find_data.dwFileAttributes) &&
- (IO_REPARSE_TAG_MOUNT_POINT == find_data.dwReserved0))
+ if (nBytesToWrite >= m_bufsiz)
{
- is_volume_root = true;
+ // buffer too small, write through to file
+ sal_uInt64 uDone = 0;
+ result = writeAt (nOffset, &(buffer[*pBytesWritten]), nBytesToWrite, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
+ if (uDone != nBytesToWrite)
+ return osl_File_E_IO;
+
+ nBytesToWrite -= sal::static_int_cast< DWORD >(uDone), *pBytesWritten += uDone;
+ return osl_File_E_None;
}
- if (IsValidHandle(h_find))
- FindClose(h_find);
- }
- }
- return is_volume_root;
- }
-
- //#####################################################
- // Has the given path a parent or are we already there,
- // e.g. 'c:\' or '\\server\share\'?
- bool has_path_parent(const sal_Unicode* path)
- {
- bool has_parent = false;
-
- if (is_UNC_path(path))
- {
- UNCComponents unc_comp;
- parse_UNC_path(path, &unc_comp);
- has_parent = unc_comp.resource_.isPresent();
- }
- else
- {
- has_parent = !osl::systemPathIsLogicalDrivePattern(path);
- }
- return has_parent;
- }
-
- //#####################################################
- // @see bool has_path_parent(const sal_Unicode* path)
- bool has_path_parent(const rtl::OUString& path)
- { return has_path_parent(path.getStr()); }
-
- //#####################################################
- bool path_get_parent(rtl::OUString& path)
- {
- OSL_PRECOND(path.lastIndexOf(SLASH) == -1, "Path must not have slashes");
- if (!has_path_parent(path))
- {
- sal_Int32 i = path.lastIndexOf(BACKSLASH);
- if (-1 < i)
- {
- path = rtl::OUString(path.getStr(), i);
- return true;
+ // update buffer (pointer)
+ sal_uInt64 uDone = 0;
+ result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
+ m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone);
}
- }
- return false;
- }
-
- //#############################################
- /* Cut off the last part of the given path to
- get the parent only, e.g. 'c:\dir\subdir' ->
- 'c:\dir' or '\\share\sub\dir' -> '\\share\sub'
- @return The position where the path has been cut
- off (this is the posistion of the last backslash).
- If there are no more parents 0 will be returned,
- e.g. 'c:\' or '\\Share' have no more parents */
- int path_make_parent(sal_Unicode* path)
- {
- OSL_PRECOND(rtl_ustr_indexOfChar(path, SLASH) != -1, "Path must not contain slashes");
- OSL_PRECOND(has_path_parent(path), "Path must have a parent");
-
- sal_Unicode* pos_last_backslash = path + rtl_ustr_lastIndexOfChar(path, BACKSLASH);
- *pos_last_backslash = 0;
- return (pos_last_backslash - path);
- }
-
- //#####################################################
- void path_travel_to_volume_root(const rtl::OUString& system_path, rtl::OUString& volume_root)
- {
- rtl::OUString sys_path(system_path);
-
- while(!is_volume_mount_point(sys_path) && path_get_parent(sys_path))
- /**/;
-
- volume_root = sys_path;
- osl_systemPathEnsureSeparator(&volume_root.pData);
- }
-
- //#####################################################
- inline bool is_floppy_A_present()
- { return (GetLogicalDrives() & 1); }
-
- //#####################################################
- inline bool is_floppy_B_present()
- { return (GetLogicalDrives() & 2); }
- //#####################################################
- // determines if a volume mount point shows to a floppy
- // disk by comparing the unique volume names
- const LPWSTR FLOPPY_A = L"A:\\";
- const LPWSTR FLOPPY_B = L"B:\\";
+ SIZE_T const bytes = std::min(m_bufsiz - bufpos, nBytesToWrite);
+ memcpy (&(m_buffer[bufpos]), &(buffer[*pBytesWritten]), bytes);
+ nBytesToWrite -= bytes, *pBytesWritten += bytes, nOffset += bytes;
- bool is_floppy_volume_mount_point(const rtl::OUString& path)
- {
- rtl::OUString p(path);
- osl_systemPathEnsureSeparator(&p.pData);
-
- TCHAR vn[51];
- if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, ELEMENTS_OF_ARRAY(vn)))
- {
- TCHAR vnfloppy[51];
- if (is_floppy_A_present() &&
- GetVolumeNameForVolumeMountPoint(FLOPPY_A, vnfloppy, ELEMENTS_OF_ARRAY(vnfloppy)) &&
- (0 == wcscmp(vn, vnfloppy)))
- return true;
-
- if (is_floppy_B_present() &&
- GetVolumeNameForVolumeMountPoint(FLOPPY_B, vnfloppy, ELEMENTS_OF_ARRAY(vnfloppy)) &&
- (0 == wcscmp(vn, vnfloppy)))
- return true;
- }
- return false;
- }
-
- //################################################
- // we must take into account that even a floppy
- // drive may be mounted to a directory so checking
- // for the drive letter alone is not sufficient
- // we must compare the unique volume name with
- // that of the available floppy disks
- LPCWSTR FLOPPY_DRV_LETTERS = TEXT("AaBb");
-
- bool is_floppy_drive(const rtl::OUString& path)
- {
- const sal_Unicode* pf = path.getStr();
- const sal_Unicode* ps = path.getStr() + 1;
- return ((wcschr(FLOPPY_DRV_LETTERS, *pf) && (L':' == *ps)) ||
- is_floppy_volume_mount_point(path));
- }
-
- //#############################################
- UINT get_volume_mount_point_drive_type(const rtl::OUString& path)
- {
- if (0 == path.getLength())
- return GetDriveType(NULL);
-
- rtl::OUString p(path);
- osl_systemPathEnsureSeparator(&p.pData);
-
- TCHAR vn[51];
- if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, ELEMENTS_OF_ARRAY(vn)))
- return GetDriveType(vn);
-
- return DRIVE_NO_ROOT_DIR;
- }
-
- //#############################################
- oslFileError osl_get_drive_type(const rtl::OUString& path, oslVolumeInfo* pInfo)
- {
- // GetDriveType fails on empty volume mount points
- // see Knowledge Base Q244089
- UINT drive_type;
- if (is_volume_mount_point(path))
- drive_type = get_volume_mount_point_drive_type(path);
- else
- drive_type = GetDriveType(reinterpret_cast<LPCTSTR>(path.getStr()));
-
- if (DRIVE_NO_ROOT_DIR == drive_type)
- return MapError(ERROR_INVALID_DRIVE);
-
- pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes;
-
- switch (drive_type)
- {
- case DRIVE_CDROM:
- pInfo->uAttributes |= osl_Volume_Attribute_CompactDisc | osl_Volume_Attribute_Removeable;
- break;
- case DRIVE_REMOVABLE:
- pInfo->uAttributes |= osl_Volume_Attribute_Removeable;
- if (is_floppy_drive(path))
- pInfo->uAttributes |= osl_Volume_Attribute_FloppyDisk;
- break;
- case DRIVE_FIXED:
- pInfo->uAttributes |= osl_Volume_Attribute_FixedDisk;
- break;
- case DRIVE_RAMDISK:
- pInfo->uAttributes |= osl_Volume_Attribute_RAMDisk;
- break;
- case DRIVE_REMOTE:
- pInfo->uAttributes |= osl_Volume_Attribute_Remote;
- break;
- case DRIVE_UNKNOWN:
- pInfo->uAttributes = 0;
- break;
- default:
- pInfo->uValidFields &= ~osl_VolumeInfo_Mask_Attributes;
- pInfo->uAttributes = 0;
- break;
+ m_buflen = std::max(m_buflen, bufpos + bytes);
+ m_state |= STATE_MODIFIED;
}
return osl_File_E_None;
}
+}
- //#############################################
- inline bool is_volume_space_info_request(sal_uInt32 field_mask)
- {
- return (field_mask &
- (osl_VolumeInfo_Mask_TotalSpace |
- osl_VolumeInfo_Mask_UsedSpace |
- osl_VolumeInfo_Mask_FreeSpace));
- }
+oslFileError FileHandle_Impl::readLineAt (
+ LONGLONG nOffset,
+ sal_Sequence ** ppSequence,
+ sal_uInt64 * pBytesRead)
+{
+ oslFileError result = osl_File_E_None;
- //#############################################
- void get_volume_space_information(const rtl::OUString& path, oslVolumeInfo *pInfo)
+ LONGLONG bufptr = (nOffset / m_bufsiz) * m_bufsiz;
+ if (bufptr != m_bufptr)
{
- BOOL ret = GetDiskFreeSpaceEx(
- reinterpret_cast<LPCTSTR>(path.getStr()),
- (PULARGE_INTEGER)&pInfo->uFreeSpace,
- (PULARGE_INTEGER)&pInfo->uTotalSpace,
- NULL);
-
- if (ret)
- {
- pInfo->uUsedSpace = pInfo->uTotalSpace - pInfo->uFreeSpace;
- pInfo->uValidFields |= osl_VolumeInfo_Mask_TotalSpace |
- osl_VolumeInfo_Mask_UsedSpace |
- osl_VolumeInfo_Mask_FreeSpace;
- }
- }
+ /* flush current buffer */
+ result = syncFile();
+ if (result != osl_File_E_None)
+ return (result);
- //#############################################
- inline bool is_filesystem_attributes_request(sal_uInt32 field_mask)
- {
- return (field_mask &
- (osl_VolumeInfo_Mask_MaxNameLength |
- osl_VolumeInfo_Mask_MaxPathLength |
- osl_VolumeInfo_Mask_FileSystemName |
- osl_VolumeInfo_Mask_FileSystemCaseHandling));
- }
+ /* update buffer (pointer) */
+ sal_uInt64 uDone = 0;
+ result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
- //#############################################
- inline bool is_drivetype_request(sal_uInt32 field_mask)
- {
- return (field_mask & osl_VolumeInfo_Mask_Attributes);
+ m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone);
}
- //#############################################
- oslFileError get_filesystem_attributes(const rtl::OUString& path, sal_uInt32 field_mask, oslVolumeInfo* pInfo)
- {
- pInfo->uAttributes = 0;
-
- oslFileError osl_error = osl_File_E_None;
+ static int const LINE_STATE_BEGIN = 0;
+ static int const LINE_STATE_CR = 1;
+ static int const LINE_STATE_LF = 2;
- // osl_get_drive_type must be called first because
- // this function resets osl_VolumeInfo_Mask_Attributes
- // on failure
- if (is_drivetype_request(field_mask))
- osl_error = osl_get_drive_type(path, pInfo);
+ SIZE_T bufpos = sal::static_int_cast< SIZE_T >(nOffset - m_bufptr), curpos = bufpos, dstpos = 0;
+ int state = (bufpos >= m_buflen) ? LINE_STATE_LF : LINE_STATE_BEGIN;
- if ((osl_File_E_None == osl_error) && is_filesystem_attributes_request(field_mask))
+ for ( ; state != LINE_STATE_LF; )
+ {
+ if (curpos >= m_buflen)
{
- WCHAR vn[MAX_PATH];
- WCHAR fsn[MAX_PATH];
- DWORD serial;
- DWORD mcl;
- DWORD flags;
-
- if (GetVolumeInformation(reinterpret_cast<LPCTSTR>(path.getStr()), vn, MAX_PATH, &serial, &mcl, &flags, fsn, MAX_PATH))
+ /* buffer examined */
+ if (0 < (curpos - bufpos))
{
- pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxNameLength;
- pInfo->uMaxNameLength = mcl;
-
- pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxPathLength;
- pInfo->uMaxPathLength = MAX_PATH;
-
- pInfo->uValidFields |= osl_VolumeInfo_Mask_FileSystemName;
- rtl_uString_newFromStr(&pInfo->ustrFileSystemName, reinterpret_cast<const sal_Unicode*>(fsn));
-
- // volumes (even NTFS) will always be considered case
- // insensitive because the Win32 API is not able to
- // deal with case sensitive volumes see M$ Knowledge Base
- // article 100625 that's why we never set the attribute
- // osl_Volume_Attribute_Case_Sensitive
-
- if (flags & FS_CASE_IS_PRESERVED)
- pInfo->uAttributes |= osl_Volume_Attribute_Case_Is_Preserved;
-
- pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes;
+ /* flush buffer to sequence */
+ result = writeSequence_Impl (
+ ppSequence, &dstpos, &(m_buffer[bufpos]), curpos - bufpos);
+ if (result != osl_File_E_None)
+ return (result);
+ *pBytesRead += curpos - bufpos, nOffset += curpos - bufpos;
}
- }
- return osl_error;
- }
- //#############################################
- // Create the specified directory and call the
- // user specified callback function. On success
- // the function returns ERROR_SUCCESS else a
- // Win32 error code.
- DWORD create_dir_with_callback(
- sal_Unicode* dir_path,
- oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
- void* pData)
- {
- if (CreateDirectory(reinterpret_cast<LPCTSTR>(dir_path), NULL))
- {
- if (aDirectoryCreationCallbackFunc)
+ bufptr = nOffset / m_bufsiz * m_bufsiz;
+ if (bufptr != m_bufptr)
{
- rtl::OUString url;
- FileBase::getFileURLFromSystemPath(dir_path, url);
- aDirectoryCreationCallbackFunc(pData, url.pData);
+ /* update buffer (pointer) */
+ sal_uInt64 uDone = 0;
+ result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
+ m_bufptr = bufptr, m_buflen = sal::static_int_cast< SIZE_T >(uDone);
}
- return ERROR_SUCCESS;
- }
- return GetLastError();
- }
-
- //#############################################
- DWORD create_dir_recursively_(
- sal_Unicode* dir_path,
- oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
- void* pData)
- {
- OSL_PRECOND(rtl_ustr_getLength(dir_path) > 0 && (rtl_ustr_lastIndexOfChar(dir_path, BACKSLASH) != rtl_ustr_getLength(dir_path) - 1), \
- "Path must not end with a backslash");
-
- DWORD w32_error = create_dir_with_callback(
- dir_path, aDirectoryCreationCallbackFunc, pData);
-
- if (w32_error == ERROR_SUCCESS)
- return ERROR_SUCCESS;
- if ((w32_error != ERROR_PATH_NOT_FOUND) || !has_path_parent(dir_path))
- return w32_error;
-
- int pos = path_make_parent(dir_path);
-
- w32_error = create_dir_recursively_(
- dir_path, aDirectoryCreationCallbackFunc, pData);
-
- if (ERROR_SUCCESS != w32_error)
- return w32_error;
-
- dir_path[pos] = BACKSLASH;
-
- return create_dir_recursively_(
- dir_path, aDirectoryCreationCallbackFunc, pData);
- }
-
- //#####################################################
- // Temp file
- //#####################################################
-
-
- //#####################################################
- oslFileError osl_setup_base_directory_impl_(
- rtl_uString* pustrDirectoryURL,
- rtl_uString** ppustr_base_dir)
- {
- rtl_uString* dir_url = 0;
- rtl_uString* dir = 0;
- oslFileError error = osl_File_E_None;
-
- if (pustrDirectoryURL)
- rtl_uString_assign(&dir_url, pustrDirectoryURL);
- else
- error = osl_getTempDirURL(&dir_url);
-
- if (osl_File_E_None == error)
- {
- error = _osl_getSystemPathFromFileURL(dir_url, &dir, sal_False);
- rtl_uString_release(dir_url);
- }
-
- if (osl_File_E_None == error )
- {
- rtl_uString_assign(ppustr_base_dir, dir);
- rtl_uString_release(dir);
- }
-
- return error;
- }
-
- //#####################################################
- oslFileError osl_setup_createTempFile_impl_(
- rtl_uString* pustrDirectoryURL,
- oslFileHandle* pHandle,
- rtl_uString** ppustrTempFileURL,
- rtl_uString** ppustr_base_dir,
- sal_Bool* b_delete_on_close)
- {
- oslFileError osl_error;
-
- OSL_PRECOND(((0 != pHandle) || (0 != ppustrTempFileURL)), "Invalid parameter!");
-
- if ((0 == pHandle) && (0 == ppustrTempFileURL))
- {
- osl_error = osl_File_E_INVAL;
- }
- else
- {
- osl_error = osl_setup_base_directory_impl_(
- pustrDirectoryURL, ppustr_base_dir);
-
- *b_delete_on_close = (sal_Bool)(0 == ppustrTempFileURL);
- }
-
- return osl_error;
- }
-
- //#####################################################
- oslFileError osl_win32_GetTempFileName_impl_(
- rtl_uString* base_directory, LPWSTR temp_file_name)
- {
- oslFileError osl_error = osl_File_E_None;
-
- if (0 == GetTempFileNameW(
- reinterpret_cast<LPCWSTR>(rtl_uString_getStr(base_directory)),
- L"",
- 0,
- temp_file_name))
- {
- osl_error = MapError(GetLastError());
- }
-
- return osl_error;
- }
-
- //#####################################################
- sal_Bool osl_win32_CreateFile_impl_(
- LPCWSTR file_name, sal_Bool b_delete_on_close, oslFileHandle* p_handle)
- {
- DWORD flags = FILE_ATTRIBUTE_NORMAL;
- HANDLE hFile;
-
- OSL_ASSERT(p_handle);
-
- if (b_delete_on_close)
- flags |= FILE_FLAG_DELETE_ON_CLOSE;
-
- hFile = CreateFileW(
- file_name,
- GENERIC_READ | GENERIC_WRITE,
- 0,
- NULL,
- TRUNCATE_EXISTING,
- flags,
- NULL);
-
- if (IsValidHandle(hFile))
- *p_handle = (oslFileHandle)hFile;
-
- return (sal_Bool)IsValidHandle(hFile);
- }
-
- //#############################################
- oslFileError osl_createTempFile_impl_(
- rtl_uString* base_directory,
- LPWSTR tmp_name,
- sal_Bool b_delete_on_close,
- oslFileHandle* pHandle,
- rtl_uString** ppustrTempFileURL)
- {
- oslFileError osl_error;
-
- do
- {
- osl_error = osl_win32_GetTempFileName_impl_(base_directory, tmp_name);
-
- /* if file could not be opened try again */
-
- if ((osl_File_E_None != osl_error) || (0 == pHandle) ||
- osl_win32_CreateFile_impl_(tmp_name, b_delete_on_close, pHandle))
+ bufpos = sal::static_int_cast< SIZE_T >(nOffset - m_bufptr), curpos = bufpos;
+ if (bufpos >= m_buflen)
break;
-
- } while(1); // try until success
-
- if ((osl_File_E_None == osl_error) && !b_delete_on_close)
- {
- rtl_uString* pustr = 0;
- rtl_uString_newFromStr(&pustr, reinterpret_cast<const sal_Unicode*>(tmp_name));
- osl_getFileURLFromSystemPath(pustr, ppustrTempFileURL);
- rtl_uString_release(pustr);
}
-
- return osl_error;
- }
-
- //#####################################################
- // End Temp file
- //#####################################################
-
-
- //#############################################
- sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedURL )
- {
- sal_Char *pBuffer;
- const sal_Char *pSrcEnd;
- const sal_Char *pSrc;
- sal_Char *pDest;
- sal_Int32 nSrcLen;
- sal_Bool bValidEncoded = sal_True; /* Assume success */
-
- /* The resulting decoded string length is shorter or equal to the source length */
-
- nSrcLen = rtl_string_getLength(strUTF8);
- pBuffer = reinterpret_cast<sal_Char*>(rtl_allocateMemory(nSrcLen + 1));
-
- pDest = pBuffer;
- pSrc = rtl_string_getStr(strUTF8);
- pSrcEnd = pSrc + nSrcLen;
-
- /* Now decode the URL what should result in an UTF8 string */
- while ( bValidEncoded && pSrc < pSrcEnd )
+ switch (state)
{
- switch ( *pSrc )
+ case LINE_STATE_CR:
+ state = LINE_STATE_LF;
+ switch (m_buffer[curpos])
{
- case '%':
- {
- sal_Char aToken[3];
- sal_Char aChar;
-
- pSrc++;
- aToken[0] = *pSrc++;
- aToken[1] = *pSrc++;
- aToken[2] = 0;
-
- aChar = (sal_Char)strtoul( aToken, NULL, 16 );
-
- /* The chars are path delimiters and must not be encoded */
-
- if ( 0 == aChar || '\\' == aChar || '/' == aChar || ':' == aChar )
- bValidEncoded = sal_False;
- else
- *pDest++ = aChar;
- }
+ case 0x0A: /* CRLF */
+ /* eat current char */
+ curpos++;
break;
- default:
- *pDest++ = *pSrc++;
+ default: /* single CR */
+ /* keep current char */
break;
}
- }
-
- *pDest++ = 0;
-
- if ( bValidEncoded ) {
- rtl_string2UString( pstrDecodedURL, pBuffer, rtl_str_getLength(pBuffer), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS );
- OSL_ASSERT(*pstrDecodedURL != 0);
- }
-
- rtl_freeMemory( pBuffer );
-
- return bValidEncoded;
- }
-
- //#############################################
- void _osl_encodeURL( rtl_uString *strURL, rtl_String **pstrEncodedURL )
- {
- /* Encode non ascii characters within the URL */
-
- rtl_String *strUTF8 = NULL;
- sal_Char *pszEncodedURL;
- const sal_Char *pURLScan;
- sal_Char *pURLDest;
- sal_Int32 nURLScanLen;
- sal_Int32 nURLScanCount;
-
- rtl_uString2String( &strUTF8, rtl_uString_getStr( strURL ), rtl_uString_getLength( strURL ), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS );
-
- pszEncodedURL = (sal_Char*) rtl_allocateMemory( (rtl_string_getLength( strUTF8 ) * 3 + 1) * sizeof(sal_Char) );
-
- pURLDest = pszEncodedURL;
- pURLScan = rtl_string_getStr( strUTF8 );
- nURLScanLen = rtl_string_getLength( strUTF8 );
- nURLScanCount = 0;
-
- while ( nURLScanCount < nURLScanLen )
- {
- sal_Char cCurrent = *pURLScan;
-
- switch ( cCurrent )
+ break;
+ default:
+ /* determine next state */
+ switch (m_buffer[curpos])
{
- default:
- if (!( ( cCurrent >= 'a' && cCurrent <= 'z' ) || ( cCurrent >= 'A' && cCurrent <= 'Z' ) || ( cCurrent >= '0' && cCurrent <= '9' ) ) )
- {
- sprintf( pURLDest, "%%%02X", (unsigned char)cCurrent );
- pURLDest += 3;
- break;
- }
- case '!':
- case '\'':
- case '(':
- case ')':
- case '*':
- case '-':
- case '.':
- case '_':
- case '~':
- case '$':
- case '&':
- case '+':
- case ',':
- case '=':
- case '@':
- case ':':
- case '/':
- case '\\':
- case '|':
- *pURLDest++ = cCurrent;
+ case 0x0A: /* single LF */
+ state = LINE_STATE_LF;
break;
- case 0:
+ case 0x0D: /* CR */
+ state = LINE_STATE_CR;
+ break;
+ default: /* advance to next char */
+ curpos++;
break;
}
-
- pURLScan++;
- nURLScanCount++;
- }
-
-
- *pURLDest = 0;
-
- rtl_string_release( strUTF8 );
- rtl_string_newFromStr( pstrEncodedURL, pszEncodedURL );
- rtl_freeMemory( pszEncodedURL );
- }
-
- //#############################################
- oslFileError SAL_CALL _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **pustrPath, sal_Bool bAllowRelative )
- {
- rtl_String *strUTF8 = NULL;
- rtl_uString *strDecodedURL = NULL;
- rtl_uString *strTempPath = NULL;
- const sal_Unicode *pDecodedURL;
- sal_uInt32 nDecodedLen;
- sal_Bool bValidEncoded;
- oslFileError nError = osl_File_E_INVAL; /* Assume failure */
-
- /* If someone hasn't encoded the complete URL we convert it to UTF8 now to prevent from
- having a mixed encoded URL later */
-
- rtl_uString2String( &strUTF8, rtl_uString_getStr( strURL ), rtl_uString_getLength( strURL ), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS );
-
- /* If the length of strUTF8 and strURL differs it indicates that the URL was not correct encoded */
-
- OSL_ENSURE_FILE(
- strUTF8->length == strURL->length ||
- 0 != rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( strURL->buffer, strURL->length, "file:\\\\", 7 )
- ,"osl_getSystemPathFromFileURL: \"%s\" is not encoded !!!", strURL );
-
- bValidEncoded = _osl_decodeURL( strUTF8, &strDecodedURL );
-
- /* Release the encoded UTF8 string */
-
- rtl_string_release( strUTF8 );
-
-
- if ( bValidEncoded )
- {
- /* Replace backslashes and pipes */
-
- rtl_uString_newReplace( &strDecodedURL, strDecodedURL, '/', '\\' );
- rtl_uString_newReplace( &strDecodedURL, strDecodedURL, '|', ':' );
-
- pDecodedURL = rtl_uString_getStr( strDecodedURL );
- nDecodedLen = rtl_uString_getLength( strDecodedURL );
-
- /* Must start with "file://" */
-
- if ( 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\", 7 ) )
- {
- sal_uInt32 nSkip;
-
- if ( 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\\\", 8 ) )
- nSkip = 8;
- else if (
- 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\localhost\\", 17 ) ||
- 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\127.0.0.1\\", 17 )
- )
- nSkip = 17;
- else
- nSkip = 5;
-
- /* Indicates local root */
- if ( nDecodedLen == nSkip )
- rtl_uString_newFromStr_WithLength( &strTempPath, reinterpret_cast<const sal_Unicode*>(WSTR_SYSTEM_ROOT_PATH), ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1 );
- else
- rtl_uString_newFromStr_WithLength( &strTempPath, pDecodedURL + nSkip, nDecodedLen - nSkip );
-
- if ( IsValidFilePath( strTempPath, NULL, VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) )
- nError = osl_File_E_None;
- }
- else if ( bAllowRelative ) /* This maybe a relative file URL */
+ if (state != LINE_STATE_BEGIN)
{
- rtl_uString_assign( &strTempPath, strDecodedURL );
-
- if ( IsValidFilePath( strTempPath, NULL, VALIDATEPATH_ALLOW_RELATIVE | VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) )
- nError = osl_File_E_None;
+ /* store (and eat) the newline char */
+ m_buffer[curpos] = 0x0A, curpos++;
+
+ /* flush buffer to sequence */
+ result = writeSequence_Impl (
+ ppSequence, &dstpos, &(m_buffer[bufpos]), curpos - bufpos - 1);
+ if (result != osl_File_E_None)
+ return (result);
+ *pBytesRead += curpos - bufpos, nOffset += curpos - bufpos;
}
- /*
- else
- OSL_ENSURE_FILE( !nError, "osl_getSystemPathFromFileURL: \"%s\" is not an absolute FileURL !!!", strURL );
- */
-
- }
-
- if ( strDecodedURL )
- rtl_uString_release( strDecodedURL );
-
- if ( osl_File_E_None == nError )
- rtl_uString_assign( pustrPath, strTempPath );
-
- if ( strTempPath )
- rtl_uString_release( strTempPath );
-
- /*
- OSL_ENSURE_FILE( !nError, "osl_getSystemPathFromFileURL: \"%s\" is not a FileURL !!!", strURL );
- */
-
- return nError;
- }
-
- //#############################################
- oslFileError SAL_CALL _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString** pstrURL )
- {
- oslFileError nError = osl_File_E_INVAL; /* Assume failure */
- rtl_uString *strTempURL = NULL;
- DWORD dwPathType = PATHTYPE_ERROR;
-
- if (strPath)
- dwPathType = IsValidFilePath(strPath, NULL, VALIDATEPATH_ALLOW_RELATIVE, NULL);
-
- if (dwPathType)
- {
- rtl_uString *strTempPath = NULL;
-
- /* Replace backslashes */
-
- rtl_uString_newReplace( &strTempPath, strPath, '\\', '/' );
-
- switch ( dwPathType & PATHTYPE_MASK_TYPE )
- {
- case PATHTYPE_RELATIVE:
- rtl_uString_assign( &strTempURL, strTempPath );
- nError = osl_File_E_None;
- break;
- case PATHTYPE_ABSOLUTE_UNC:
- rtl_uString_newFromAscii( &strTempURL, "file:" );
- rtl_uString_newConcat( &strTempURL, strTempURL, strTempPath );
- nError = osl_File_E_None;
- break;
- case PATHTYPE_ABSOLUTE_LOCAL:
- rtl_uString_newFromAscii( &strTempURL, "file:///" );
- rtl_uString_newConcat( &strTempURL, strTempURL, strTempPath );
- nError = osl_File_E_None;
- break;
- default:
- break;
- }
-
- /* Release temp path */
-
- rtl_uString_release( strTempPath );
- }
-
- if ( osl_File_E_None == nError )
- {
- rtl_String *strEncodedURL = NULL;
-
- /* Encode the URL */
-
- _osl_encodeURL( strTempURL, &strEncodedURL );
-
- /* Provide URL via unicode string */
-
- rtl_string2UString( pstrURL, rtl_string_getStr(strEncodedURL), rtl_string_getLength(strEncodedURL), RTL_TEXTENCODING_ASCII_US, OUSTRING_TO_OSTRING_CVTFLAGS );
- OSL_ASSERT(*pstrURL != 0);
- rtl_string_release( strEncodedURL );
- }
-
- /* Release temp URL */
-
- if ( strTempURL )
- rtl_uString_release( strTempURL );
-
- /*
- OSL_ENSURE_FILE( !nError, "osl_getFileURLFromSystemPath: \"%s\" is not a systemPath !!!", strPath );
- */
-
- return nError;
- }
-
-#if OSL_DEBUG_LEVEL > 0
-
- //#####################################################
- void _osl_warnFile( const char *message, rtl_uString *ustrFile )
- {
- char szBuffer[2048];
-
- if (ustrFile)
- {
- rtl_String *strFile = NULL;
-
- rtl_uString2String( &strFile, rtl_uString_getStr( ustrFile ), rtl_uString_getLength( ustrFile ), osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS );
- snprintf( szBuffer, sizeof(szBuffer), message, strFile->buffer );
- rtl_string_release( strFile );
-
- message = szBuffer;
+ break;
}
- OSL_ENSURE( 0, message );
- }
-
-#endif // OSL_DEBUG_LEVEL > 0
-
-} // end namespace private
-
-
-//#####################################################
-// Exported OSL API
-//#####################################################
-
-
-//#############################################
-oslFileError SAL_CALL osl_getVolumeInformation(
- rtl_uString *ustrURL, oslVolumeInfo *pInfo, sal_uInt32 uFieldMask )
-{
- if (!pInfo)
- return osl_File_E_INVAL;
-
- rtl::OUString system_path;
- oslFileError error = _osl_getSystemPathFromFileURL(ustrURL, &system_path.pData, sal_False);
-
- if (osl_File_E_None != error)
- return error;
-
- rtl::OUString volume_root;
- path_travel_to_volume_root(system_path, volume_root);
-
- pInfo->uValidFields = 0;
-
- if ((error = get_filesystem_attributes(volume_root, uFieldMask, pInfo)) != osl_File_E_None)
- return error;
-
- if (is_volume_space_info_request(uFieldMask))
- get_volume_space_information(volume_root, pInfo);
-
- if (uFieldMask & osl_VolumeInfo_Mask_DeviceHandle)
- {
- pInfo->uValidFields |= osl_VolumeInfo_Mask_DeviceHandle;
- osl_getFileURLFromSystemPath(volume_root.pData, (rtl_uString**)&pInfo->pDeviceHandle);
}
+ result = writeSequence_Impl (ppSequence, &dstpos, 0, 0);
+ if (result != osl_File_E_None)
+ return (result);
+ if (0 < dstpos)
+ return osl_File_E_None;
+ if (bufpos >= m_buflen)
+ return osl_File_E_AGAIN;
return osl_File_E_None;
}
-
-//#############################################
-oslFileError SAL_CALL osl_createDirectoryPath(
- rtl_uString* aDirectoryUrl,
- oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
- void* pData)
-{
- if (aDirectoryUrl == NULL)
- return osl_File_E_INVAL;
-
- rtl::OUString sys_path;
- oslFileError osl_error =
- _osl_getSystemPathFromFileURL(aDirectoryUrl, &sys_path.pData, sal_False);
-
- if (osl_error != osl_File_E_None)
- return osl_error;
-
- systemPathRemoveSeparator(sys_path);
-
- // const_cast because sys_path is a local copy
- // which we want to modify inplace instead of
- // coyp it into another buffer on the heap again
- return MapError(create_dir_recursively_(
- sys_path.pData->buffer, aDirectoryCreationCallbackFunc, pData));
-}
-
-//#############################################
-oslFileError SAL_CALL osl_createTempFile(
- rtl_uString* pustrDirectoryURL,
- oslFileHandle* pHandle,
- rtl_uString** ppustrTempFileURL)
+oslFileError FileHandle_Impl::writeSequence_Impl (
+ sal_Sequence ** ppSequence,
+ SIZE_T * pnOffset,
+ const void * pBuffer,
+ SIZE_T nBytes)
{
- rtl_uString* base_directory = 0;
- LPWSTR tmp_name;
- sal_Bool b_delete_on_close;
- oslFileError osl_error;
-
- osl_error = osl_setup_createTempFile_impl_(
- pustrDirectoryURL,
- pHandle,
- ppustrTempFileURL,
- &base_directory,
- &b_delete_on_close);
-
- if (osl_File_E_None != osl_error)
- return osl_error;
-
- /* allocate enough space on the stack */
- STACK_ALLOC(tmp_name, WCHAR, (rtl_uString_getLength(base_directory) + MAX_PATH));
-
- if (tmp_name)
+ sal_Int32 nElements = *pnOffset + nBytes;
+ if (!*ppSequence)
{
- osl_createTempFile_impl_(
- base_directory,
- tmp_name,
- b_delete_on_close,
- pHandle,
- ppustrTempFileURL);
+ /* construct sequence */
+ rtl_byte_sequence_constructNoDefault(ppSequence, nElements);
}
- else // stack alloc failed
+ else if (nElements != (*ppSequence)->nElements)
{
- osl_error = osl_File_E_NOMEM;
+ /* resize sequence */
+ rtl_byte_sequence_realloc(ppSequence, nElements);
}
-
- if (base_directory)
- rtl_uString_release(base_directory);
-
- return osl_error;
-}
-
-//#############################################
-oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir)
-{
- WCHAR szBuffer[MAX_PATH];
- LPWSTR lpBuffer = szBuffer;
- DWORD nBufferLength = ELEMENTS_OF_ARRAY(szBuffer) - 1;
-
- DWORD nLength;
- oslFileError error;
-
- do
- {
- nLength = GetTempPathW( ELEMENTS_OF_ARRAY(szBuffer), lpBuffer );
- if ( nLength > nBufferLength )
- {
- nLength++;
- lpBuffer = reinterpret_cast<WCHAR*>(alloca( sizeof(WCHAR) * nLength ));
- nBufferLength = nLength - 1;
- }
- } while ( nLength > nBufferLength );
-
- if ( nLength )
+ if (*ppSequence != 0)
{
- rtl_uString *ustrTempPath = NULL;
-
- if ( '\\' == lpBuffer[nLength-1] )
- lpBuffer[nLength-1] = 0;
-
- rtl_uString_newFromStr( &ustrTempPath, reinterpret_cast<const sal_Unicode*>(lpBuffer) );
-
- error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir );
-
- rtl_uString_release( ustrTempPath );
+ /* fill sequence */
+ memcpy(&((*ppSequence)->elements[*pnOffset]), pBuffer, nBytes), *pnOffset += nBytes;
}
- else
- error = MapError( GetLastError() );
+ return (*ppSequence != 0) ? osl_File_E_None : osl_File_E_NOMEM;
+}
- return error;
+oslFileError FileHandle_Impl::syncFile()
+{
+ oslFileError result = osl_File_E_None;
+ if (m_state & STATE_MODIFIED)
+ {
+ sal_uInt64 uDone = 0;
+ result = writeAt (m_bufptr, m_buffer, m_buflen, &uDone);
+ if (result != osl_File_E_None)
+ return (result);
+ if (uDone != m_buflen)
+ return osl_File_E_IO;
+ m_state &= ~STATE_MODIFIED;
+ }
+ return (result);
}
//##################################################################
-// File handling functions
+// File I/O functions
//##################################################################
-
-//#############################################
-oslFileError SAL_CALL osl_openFile(
- rtl_uString *strPath, oslFileHandle *pHandle, sal_uInt32 uFlags )
+extern "C" oslFileHandle
+SAL_CALL osl_createFileHandleFromOSHandle (
+ HANDLE hFile,
+ sal_uInt32 uFlags)
{
- rtl_uString *strSysPath = NULL;
- oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
+ if ( !IsValidHandle(hFile) )
+ return 0; // EINVAL
- if ( osl_File_E_None == error )
+ FileHandle_Impl * pImpl = new FileHandle_Impl(hFile);
+ if (pImpl == 0)
{
- DWORD dwAccess = 0, dwShare = FILE_SHARE_READ, dwCreation = 0, dwAttributes = 0;
- HANDLE hFile;
-
- if ( uFlags & osl_File_OpenFlag_Read )
- dwAccess |= GENERIC_READ;
-
- if ( uFlags & osl_File_OpenFlag_Write )
- dwAccess |= GENERIC_WRITE;
- else
- dwShare |= FILE_SHARE_WRITE;
-
- if ( uFlags & osl_File_OpenFlag_NoLock )
- dwShare |= FILE_SHARE_WRITE;
-
- if ( uFlags & osl_File_OpenFlag_Create )
- dwCreation |= CREATE_NEW;
- else
- dwCreation |= OPEN_EXISTING;
-
- hFile = CreateFileW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strSysPath )), dwAccess, dwShare, NULL, dwCreation, dwAttributes, NULL );
-
- *pHandle = osl_createFileHandleFromOSHandle( hFile );
-
- if ( !IsValidHandle( hFile ) )
- error = MapError( GetLastError() );
-
- rtl_uString_release( strSysPath );
+ // cleanup and fail
+ (void) ::CloseHandle(hFile);
+ return 0; // ENOMEM
}
- return error;
-}
-
-//#############################################
-oslFileError SAL_CALL osl_syncFile(oslFileHandle Handle)
-{
- if (!IsValidHandle((HANDLE)Handle))
- return osl_File_E_INVAL;
-
- if (!FlushFileBuffers((HANDLE)Handle))
- return MapError(GetLastError());
-
- return osl_File_E_None;
-}
+ /* check for regular file */
+ if (FILE_TYPE_DISK == GetFileType(hFile))
+ {
+ /* mark seekable */
+ pImpl->m_state |= FileHandle_Impl::STATE_SEEKABLE;
-//#############################################
-oslFileError SAL_CALL osl_closeFile(oslFileHandle Handle)
-{
- oslFileError error;
- HANDLE hFile = (HANDLE)Handle;
+ /* init current size */
+ LARGE_INTEGER uSize = { 0, 0 };
+ (void) ::GetFileSizeEx(hFile, &uSize);
+ pImpl->m_size = (sal::static_int_cast<sal_uInt64>(uSize.HighPart) << 32) + uSize.LowPart;
+ }
- if ( IsValidHandle(hFile) )
- error = CloseHandle( hFile ) ? osl_File_E_None : MapError( GetLastError() );
- else
- error = osl_File_E_INVAL;
+ if (!(uFlags & osl_File_OpenFlag_Read))
+ pImpl->m_state &= ~FileHandle_Impl::STATE_READABLE;
+ if (!(uFlags & osl_File_OpenFlag_Write))
+ pImpl->m_state &= ~FileHandle_Impl::STATE_WRITEABLE;
- return error;
+ OSL_POSTCOND(
+ (uFlags & osl_File_OpenFlag_Read) || (uFlags & osl_File_OpenFlag_Write),
+ "osl_createFileHandleFromOSHandle(): missing read/write access flags");
+ return (oslFileHandle)(pImpl);
}
//#############################################
-oslFileError SAL_CALL osl_isEndOfFile(oslFileHandle Handle, sal_Bool *pIsEOF)
+oslFileError
+SAL_CALL osl_openFile(
+ rtl_uString * strPath,
+ oslFileHandle * pHandle,
+ sal_uInt32 uFlags )
{
- oslFileError error = osl_File_E_INVAL;
- HANDLE hFile = (HANDLE)Handle;
+ rtl_uString * strSysPath = 0;
+ oslFileError result = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
+ if (result != osl_File_E_None)
+ return (result);
- if ( IsValidHandle(hFile) )
- {
- LONG lDistanceToMove, lDistanceToMoveHigh;
- sal_uInt64 nCurPos;
-
- /* Return value INVALID_SET_FILE_POINTER is no error indication and LastError could
- be set from previous IO call */
-
- SetLastError( NOERROR );
-
- lDistanceToMoveHigh = 0;
- lDistanceToMove = SetFilePointer( hFile, 0, &lDistanceToMoveHigh, FILE_CURRENT );
-
- error = MapError( GetLastError() );
+ DWORD dwAccess = GENERIC_READ, dwShare = FILE_SHARE_READ, dwCreation = 0, dwAttributes = 0;
- if ( osl_File_E_None == error )
- {
- nCurPos = (sal_uInt64)lDistanceToMove + ((sal_uInt64)lDistanceToMoveHigh << 32);
+ if ( uFlags & osl_File_OpenFlag_Write )
+ dwAccess |= GENERIC_WRITE;
+ else
+ dwShare |= FILE_SHARE_WRITE;
- lDistanceToMoveHigh = 0;
- lDistanceToMove = SetFilePointer( hFile, 0, &lDistanceToMoveHigh, FILE_END );
+ if ( uFlags & osl_File_OpenFlag_NoLock )
+ dwShare |= FILE_SHARE_WRITE;
- error = MapError( GetLastError() );
+ if ( uFlags & osl_File_OpenFlag_Create )
+ dwCreation |= CREATE_NEW;
+ else
+ dwCreation |= OPEN_EXISTING;
- if ( osl_File_E_None == error )
- {
- sal_uInt64 nEndPos = (sal_uInt64)lDistanceToMove + ((sal_uInt64)lDistanceToMoveHigh << 32);
+ HANDLE hFile = CreateFileW(
+ reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strSysPath )),
+ dwAccess, dwShare, NULL, dwCreation, dwAttributes, NULL );
- *pIsEOF = (sal_Bool)(nEndPos == nCurPos);
+ // @@@ ERROR HANDLING @@@
+ if ( !IsValidHandle( hFile ) )
+ result = oslTranslateFileError( GetLastError() );
- lDistanceToMoveHigh = (LONG)(nCurPos >> 32);
- SetFilePointer( hFile, (LONG)(nCurPos & 0xFFFFFFFF), &lDistanceToMoveHigh, FILE_BEGIN );
+ *pHandle = osl_createFileHandleFromOSHandle (hFile, uFlags | osl_File_OpenFlag_Read);
- error = MapError( GetLastError() );
- }
- }
- }
- return error;
+ rtl_uString_release( strSysPath );
+ return (result);
}
//#############################################
-oslFileError SAL_CALL osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uPos)
+oslFileError
+SAL_CALL osl_syncFile(oslFileHandle Handle)
{
- HANDLE hFile = (HANDLE)Handle;
- if (!IsValidHandle(hFile))
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
+ if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile))
return osl_File_E_INVAL;
- DWORD dwMoveMethod = 0;
- switch ( uHow )
- {
- case osl_Pos_Current:
- dwMoveMethod = FILE_CURRENT;
- break;
- case osl_Pos_End:
- dwMoveMethod = FILE_END;
- break;
- case osl_Pos_Absolut:
- default:
- dwMoveMethod = FILE_BEGIN;
- break;
- }
+ oslFileError result = pImpl->syncFile();
+ if (result != osl_File_E_None)
+ return result;
- LONG nOffsetLo = sal::static_int_cast<LONG>(uPos & 0xFFFFFFFF);
- LONG nOffsetHi = sal::static_int_cast<LONG>(uPos >> 32);
+ if (!FlushFileBuffers(pImpl->m_hFile))
+ return oslTranslateFileError(GetLastError());
- SetLastError(0);
- DWORD dwPosLo = SetFilePointer( hFile, nOffsetLo, &nOffsetHi, dwMoveMethod );
- if (INVALID_SET_FILE_POINTER == dwPosLo)
- {
- DWORD dwError = GetLastError();
- if (NO_ERROR != dwError)
- return MapError( dwError );
- }
return osl_File_E_None;
}
//#############################################
-oslFileError SAL_CALL osl_getFilePos(oslFileHandle Handle, sal_uInt64 *pPos)
+oslFileError
+SAL_CALL osl_closeFile(oslFileHandle Handle)
{
- oslFileError error;
- HANDLE hFile = (HANDLE)Handle;
-
- if ( IsValidHandle(hFile) )
- {
- LONG lDistanceToMove, lDistanceToMoveHigh;
-
- /* Return value INVALID_SET_FILE_POINTER is no error indication and LastError could
- be set from previous IO call */
-
- SetLastError( NOERROR );
-
- lDistanceToMoveHigh = 0;
- lDistanceToMove = SetFilePointer( hFile, 0, &lDistanceToMoveHigh, FILE_CURRENT );
-
- error = MapError( GetLastError() );
-
- if ( osl_File_E_None == error )
- *pPos = (sal_uInt64)lDistanceToMove + ((sal_uInt64)lDistanceToMoveHigh << 32);
- }
- else
- error = osl_File_E_INVAL;
-
- return error;
-}
-
-//#############################################
-oslFileError SAL_CALL osl_getFileSize(oslFileHandle Handle, sal_uInt64 *pSize)
-{
- HANDLE hFile = (HANDLE)Handle;
- if ( !IsValidHandle(hFile) )
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
+ if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile))
return osl_File_E_INVAL;
- DWORD nSize = GetFileSize(hFile, NULL);
- if (nSize == INVALID_FILE_SIZE)
+ oslFileError result = pImpl->syncFile();
+ if (result != osl_File_E_None)
{
- DWORD nError = GetLastError();
- if (nError != NO_ERROR)
- return MapError(nError);
+ /* ignore double failure */
+ (void)::CloseHandle(pImpl->m_hFile);
}
-
- *pSize = (sal_uInt64)(nSize);
- return osl_File_E_None;
-}
-
-oslFileError SAL_CALL osl_setFileSize(oslFileHandle Handle, sal_uInt64 uSize)
-{
- oslFileError error = osl_setFilePos( Handle, osl_Pos_Absolut, uSize );
- if ( osl_File_E_None == error )
+ else if (!::CloseHandle(pImpl->m_hFile))
{
- if ( !SetEndOfFile( (HANDLE)Handle ) )
- error = MapError( osl_File_E_None );
+ /* translate error code */
+ result = oslTranslateFileError( GetLastError() );
}
- return error;
+ delete pImpl;
+ return (result);
}
//#############################################
-oslFileError SAL_CALL osl_mapFile(
+oslFileError
+SAL_CALL osl_mapFile(
oslFileHandle Handle,
void** ppAddr,
sal_uInt64 uLength,
@@ -2710,8 +768,8 @@ oslFileError SAL_CALL osl_mapFile(
}
};
- HANDLE hFile = (HANDLE)(Handle);
- if (!IsValidHandle(hFile) || (0 == ppAddr))
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
+ if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == ppAddr))
return osl_File_E_INVAL;
*ppAddr = 0;
@@ -2727,16 +785,16 @@ oslFileError SAL_CALL osl_mapFile(
if (VER_PLATFORM_WIN32_NT != osinfo.dwPlatformId)
return osl_File_E_NOSYS; // Unsupported
- FileMapping aMap( ::CreateFileMapping (hFile, NULL, SEC_COMMIT | PAGE_READONLY, 0, 0, NULL) );
+ FileMapping aMap( ::CreateFileMapping (pImpl->m_hFile, NULL, SEC_COMMIT | PAGE_READONLY, 0, 0, NULL) );
if (!IsValidHandle(aMap.m_handle))
- return MapError( GetLastError() );
+ return oslTranslateFileError( GetLastError() );
DWORD const dwOffsetHi = sal::static_int_cast<DWORD>(uOffset >> 32);
DWORD const dwOffsetLo = sal::static_int_cast<DWORD>(uOffset & 0xFFFFFFFF);
*ppAddr = ::MapViewOfFile( aMap.m_handle, FILE_MAP_READ, dwOffsetHi, dwOffsetLo, nLength );
if (0 == *ppAddr)
- return MapError( GetLastError() );
+ return oslTranslateFileError( GetLastError() );
if (uFlags & osl_File_MapFlag_RandomAccess)
{
@@ -2770,977 +828,320 @@ oslFileError SAL_CALL osl_mapFile(
}
//#############################################
-oslFileError SAL_CALL osl_unmapFile(void* pAddr, sal_uInt64 /* uLength */)
+oslFileError
+SAL_CALL osl_unmapFile(void* pAddr, sal_uInt64 /* uLength */)
{
if (0 == pAddr)
return osl_File_E_INVAL;
if (!::UnmapViewOfFile (pAddr))
- return MapError( GetLastError() );
+ return oslTranslateFileError( GetLastError() );
return osl_File_E_None;
}
//#############################################
-oslFileError SAL_CALL osl_readFile(
- oslFileHandle Handle,
- void *pBuffer,
- sal_uInt64 uBytesRequested,
- sal_uInt64 *pBytesRead )
+oslFileError
+SAL_CALL osl_readLine(
+ oslFileHandle Handle,
+ sal_Sequence ** ppSequence)
{
- oslFileError error;
- HANDLE hFile = (HANDLE)Handle;
-
- if ( IsValidHandle(hFile) )
- {
- DWORD dwBytesToRead = (DWORD)uBytesRequested;
- DWORD dwBytesRead;
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
+ if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == ppSequence))
+ return osl_File_E_INVAL;
+ sal_uInt64 uBytesRead = 0;
+
+ // read at current filepos; filepos += uBytesRead;
+ oslFileError result = pImpl->readLineAt (
+ pImpl->m_filepos, ppSequence, &uBytesRead);
+ if (result == osl_File_E_None)
+ pImpl->m_filepos += uBytesRead;
+ return (result);
+}
- if ( ReadFile( hFile, pBuffer, dwBytesToRead, &dwBytesRead, NULL ) )
- {
- *pBytesRead = (sal_uInt64)dwBytesRead;
- error = osl_File_E_None;
- }
- else
- error = MapError( GetLastError() );
- }
- else
- error = osl_File_E_INVAL;
+//#############################################
+oslFileError
+SAL_CALL osl_readFile(
+ oslFileHandle Handle,
+ void * pBuffer,
+ sal_uInt64 uBytesRequested,
+ sal_uInt64 * pBytesRead)
+{
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
+ if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesRead))
+ return osl_File_E_INVAL;
- return error;
+ // read at current filepos; filepos += *pBytesRead;
+ oslFileError result = pImpl->readFileAt (
+ pImpl->m_filepos, pBuffer, uBytesRequested, pBytesRead);
+ if (result == osl_File_E_None)
+ pImpl->m_filepos += *pBytesRead;
+ return (result);
}
//#############################################
-oslFileError SAL_CALL osl_writeFile(
+oslFileError
+SAL_CALL osl_writeFile(
oslFileHandle Handle,
- const void *pBuffer,
- sal_uInt64 uBytesToWrite,
- sal_uInt64 *pBytesWritten )
+ const void * pBuffer,
+ sal_uInt64 uBytesToWrite,
+ sal_uInt64 * pBytesWritten )
{
- oslFileError error;
- HANDLE hFile = (HANDLE)Handle;
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ( IsValidHandle(hFile) )
- {
- DWORD dwBytesToWrite = (DWORD)uBytesToWrite;
- DWORD dwBytesWritten;
-
- if ( WriteFile( hFile, pBuffer, dwBytesToWrite, &dwBytesWritten, NULL ) )
- {
- *pBytesWritten = (sal_uInt64)dwBytesWritten;
- error = osl_File_E_None;
- }
- else
- error = MapError( GetLastError() );
- }
- else
- error = osl_File_E_INVAL;
+ if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesWritten))
+ return osl_File_E_INVAL;
- return error;
+ // write at current filepos; filepos += *pBytesWritten;
+ oslFileError result = pImpl->writeFileAt (
+ pImpl->m_filepos, pBuffer, uBytesToWrite, pBytesWritten);
+ if (result == osl_File_E_None)
+ pImpl->m_filepos += *pBytesWritten;
+ return (result);
}
//#############################################
-oslFileError SAL_CALL osl_readFileAt(
+oslFileError
+SAL_CALL osl_readFileAt(
oslFileHandle Handle,
sal_uInt64 uOffset,
void* pBuffer,
sal_uInt64 uBytesRequested,
sal_uInt64* pBytesRead)
{
- HANDLE hFile = (HANDLE)(Handle);
- if (!IsValidHandle(hFile) || (0 == pBuffer))
- return osl_File_E_INVAL;
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- static sal_uInt64 const g_limit_dword = std::numeric_limits< DWORD >::max();
- if (g_limit_dword < uBytesRequested)
- return osl_File_E_OVERFLOW;
- DWORD const dwBytes = sal::static_int_cast< DWORD >(uBytesRequested);
-
- if (0 == pBytesRead)
+ if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesRead))
return osl_File_E_INVAL;
- *pBytesRead = 0;
-
- oslFileError error = osl_setFilePos(Handle, osl_Pos_Absolut, uOffset);
- if (osl_File_E_None != error)
- return error;
+ if (0 == (pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE))
+ return osl_File_E_SPIPE;
- DWORD dwDone = 0;
- if (!::ReadFile(hFile, pBuffer, dwBytes, &dwDone, NULL))
- return MapError( GetLastError() );
+ static sal_uInt64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max();
+ if (g_limit_longlong < uOffset)
+ return osl_File_E_OVERFLOW;
+ LONGLONG const nOffset = sal::static_int_cast< LONGLONG >(uOffset);
- *pBytesRead = dwDone;
- return osl_File_E_None;
+ // read at specified fileptr
+ return pImpl->readFileAt (nOffset, pBuffer, uBytesRequested, pBytesRead);
}
//#############################################
-oslFileError SAL_CALL osl_writeFileAt(
+oslFileError
+SAL_CALL osl_writeFileAt(
oslFileHandle Handle,
sal_uInt64 uOffset,
const void* pBuffer,
sal_uInt64 uBytesToWrite,
sal_uInt64* pBytesWritten)
{
- HANDLE hFile = (HANDLE)(Handle);
- if (!IsValidHandle(hFile) || (0 == pBuffer))
- return osl_File_E_INVAL;
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- static sal_uInt64 const g_limit_dword = std::numeric_limits< DWORD >::max();
- if (g_limit_dword < uBytesToWrite)
- return osl_File_E_OVERFLOW;
- DWORD const dwBytes = sal::static_int_cast< DWORD >(uBytesToWrite);
-
- if (0 == pBytesWritten)
+ if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pBuffer) || (0 == pBytesWritten))
return osl_File_E_INVAL;
- *pBytesWritten = 0;
-
- oslFileError error = osl_setFilePos(Handle, osl_Pos_Absolut, uOffset);
- if (osl_File_E_None != error)
- return error;
+ if (0 == (pImpl->m_state & FileHandle_Impl::STATE_SEEKABLE))
+ return osl_File_E_SPIPE;
- DWORD dwDone = 0;
- if (!::WriteFile(hFile, pBuffer, dwBytes, &dwDone, NULL))
- return MapError( GetLastError() );
+ static sal_uInt64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max();
+ if (g_limit_longlong < uOffset)
+ return osl_File_E_OVERFLOW;
+ LONGLONG const nOffset = sal::static_int_cast< LONGLONG >(uOffset);
- *pBytesWritten = dwDone;
- return osl_File_E_None;
+ // write at specified fileptr
+ return pImpl->writeFileAt (nOffset, pBuffer, uBytesToWrite, pBytesWritten);
}
//#############################################
-oslFileError SAL_CALL osl_removeFile( rtl_uString* strPath )
+oslFileError
+SAL_CALL osl_isEndOfFile (oslFileHandle Handle, sal_Bool *pIsEOF)
{
- rtl_uString *strSysPath = NULL;
- oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
-
- if ( osl_File_E_None == error )
- {
- if ( DeleteFile( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )) ) )
- error = osl_File_E_None;
- else
- error = MapError( GetLastError() );
-
- rtl_uString_release( strSysPath );
- }
- return error;
-}
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
-//#############################################
-#define osl_File_CopyRecursive 0x0001
-#define osl_File_CopyOverwrite 0x0002
-
-oslFileError SAL_CALL osl_copyFile( rtl_uString* strPath, rtl_uString *strDestPath )
-{
- rtl_uString *strSysPath = NULL, *strSysDestPath = NULL;
- oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
-
- if ( osl_File_E_None == error )
- error = _osl_getSystemPathFromFileURL( strDestPath, &strSysDestPath, sal_False );
-
- if ( osl_File_E_None == error )
- {
- if ( CopyFile( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )), reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysDestPath )), FALSE ) )
- error = osl_File_E_None;
- else
- error = MapError( GetLastError() );
- }
-
- if ( strSysPath )
- rtl_uString_release( strSysPath );
- if ( strSysDestPath )
- rtl_uString_release( strSysDestPath );
+ if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pIsEOF))
+ return osl_File_E_INVAL;
- return error;
+ *pIsEOF = (pImpl->getPos() == pImpl->getSize());
+ return osl_File_E_None;
}
//#############################################
-oslFileError SAL_CALL osl_moveFile( rtl_uString* strPath, rtl_uString *strDestPath )
+oslFileError
+SAL_CALL osl_getFilePos(oslFileHandle Handle, sal_uInt64 *pPos)
{
- rtl_uString *strSysPath = NULL, *strSysDestPath = NULL;
- oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
-
- if ( osl_File_E_None == error )
- error = _osl_getSystemPathFromFileURL( strDestPath, &strSysDestPath, sal_False );
-
- if ( osl_File_E_None == error )
- {
- if ( MoveFileEx( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )), reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysDestPath )), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH | MOVEFILE_REPLACE_EXISTING ) )
- error = osl_File_E_None;
- else
- error = MapError( GetLastError() );
- }
-
- if ( strSysPath )
- rtl_uString_release( strSysPath );
- if ( strSysDestPath )
- rtl_uString_release( strSysDestPath );
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
+ if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pPos))
+ return osl_File_E_INVAL;
- return error;
+ *pPos = pImpl->getPos();
+ return osl_File_E_None;
}
//#############################################
-oslFileError SAL_CALL osl_setFileAttributes(
- rtl_uString *ustrFileURL,
- sal_uInt64 uAttributes )
+oslFileError
+SAL_CALL osl_setFilePos(oslFileHandle Handle, sal_uInt32 uHow, sal_Int64 uOffset)
{
- oslFileError error;
- rtl_uString *ustrSysPath = NULL;
- DWORD dwFileAttributes;
- BOOL fSuccess;
-
- // Converts the normalized path into a systempath
- error = _osl_getSystemPathFromFileURL( ustrFileURL, &ustrSysPath, sal_False );
-
- if ( osl_File_E_None != error )
- return error;
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
+ if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile))
+ return osl_File_E_INVAL;
- dwFileAttributes = GetFileAttributes( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(ustrSysPath)) );
+ static sal_Int64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max();
+ if (g_limit_longlong < uOffset)
+ return osl_File_E_OVERFLOW;
+ LONGLONG nPos = 0, nOffset = sal::static_int_cast< LONGLONG >(uOffset);
- if ( (DWORD)-1 != dwFileAttributes )
+ switch (uHow)
{
- dwFileAttributes &= ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN);
+ case osl_Pos_Absolut:
+ if (0 > nOffset)
+ return osl_File_E_INVAL;
+ break;
- if ( uAttributes & osl_File_Attribute_ReadOnly )
- dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
+ case osl_Pos_Current:
+ nPos = sal::static_int_cast< LONGLONG >(pImpl->getPos());
+ if ((0 > nOffset) && (-1*nOffset > nPos))
+ return osl_File_E_INVAL;
+ if (g_limit_longlong < nPos + nOffset)
+ return osl_File_E_OVERFLOW;
+ break;
- if ( uAttributes & osl_File_Attribute_Hidden )
- dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;
+ case osl_Pos_End:
+ nPos = sal::static_int_cast< LONGLONG >(pImpl->getSize());
+ if ((0 > nOffset) && (-1*nOffset > nPos))
+ return osl_File_E_INVAL;
+ if (g_limit_longlong < nPos + nOffset)
+ return osl_File_E_OVERFLOW;
+ break;
- fSuccess = SetFileAttributes( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(ustrSysPath)), dwFileAttributes );
+ default:
+ return osl_File_E_INVAL;
}
- else
- fSuccess = FALSE;
- if ( !fSuccess )
- error = MapError( GetLastError() );
-
- rtl_uString_release( ustrSysPath );
-
- return error;
+ return pImpl->setPos (nPos + nOffset);
}
-//#####################################################
-oslFileError SAL_CALL osl_setFileTime(
- rtl_uString *filePath,
- const TimeValue *aCreationTime,
- const TimeValue *aLastAccessTime,
- const TimeValue *aLastWriteTime)
+//#############################################
+oslFileError
+SAL_CALL osl_getFileSize (oslFileHandle Handle, sal_uInt64 *pSize)
{
- oslFileError error;
- rtl_uString *sysPath=NULL;
- FILETIME *lpCreationTime=NULL;
- FILETIME *lpLastAccessTime=NULL;
- FILETIME *lpLastWriteTime=NULL;
- FILETIME ftCreationTime;
- FILETIME ftLastAccessTime;
- FILETIME ftLastWriteTime;
- HANDLE hFile;
- BOOL fSuccess;
-
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- error=_osl_getSystemPathFromFileURL(filePath, &sysPath, sal_False);
-
- if (error==osl_File_E_INVAL)
- return error;
-
- hFile=CreateFileW(reinterpret_cast<LPCWSTR>(rtl_uString_getStr(sysPath)), GENERIC_WRITE, 0, NULL , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- rtl_uString_release(sysPath);
-
- if (hFile==INVALID_HANDLE_VALUE)
- return osl_File_E_NOENT;
-
- if (TimeValueToFileTime(aCreationTime, &ftCreationTime))
- lpCreationTime=&ftCreationTime;
-
- if (TimeValueToFileTime(aLastAccessTime, &ftLastAccessTime))
- lpLastAccessTime=&ftLastAccessTime;
-
- if (TimeValueToFileTime(aLastWriteTime, &ftLastWriteTime))
- lpLastWriteTime=&ftLastWriteTime;
-
- fSuccess=SetFileTime(hFile, lpCreationTime, lpLastAccessTime, lpLastWriteTime);
-
- CloseHandle(hFile);
-
- if (!fSuccess)
+ if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile) || (0 == pSize))
return osl_File_E_INVAL;
- else
- return osl_File_E_None;
+
+ *pSize = pImpl->getSize();
+ return osl_File_E_None;
}
-//#####################################################
-oslFileError SAL_CALL osl_getFileStatus(
- oslDirectoryItem Item,
- oslFileStatus *pStatus,
- sal_uInt32 uFieldMask )
+//#############################################
+oslFileError
+SAL_CALL osl_setFileSize (oslFileHandle Handle, sal_uInt64 uSize)
{
- DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
+ FileHandle_Impl * pImpl = static_cast<FileHandle_Impl*>(Handle);
- if ( !pItemImpl )
+ if ((0 == pImpl) || !IsValidHandle(pImpl->m_hFile))
return osl_File_E_INVAL;
+ if (0 == (pImpl->m_state & FileHandle_Impl::STATE_WRITEABLE))
+ return osl_File_E_BADF;
- switch ( pItemImpl->uType )
- {
- case DIRECTORYITEM_DRIVE:
- return osl_getDriveInfo( Item, pStatus, uFieldMask );
- case DIRECTORYITEM_SERVER:
- return osl_getServerInfo( Item, pStatus, uFieldMask );
- default:
- break;
- }
-
- if ( uFieldMask & osl_FileStatus_Mask_Validate )
- {
- HANDLE hFind = FindFirstFile( pItemImpl->szFullPath, &pItemImpl->FindData );
-
- if ( hFind != INVALID_HANDLE_VALUE )
- FindClose( hFind );
- else
- return MapError( GetLastError() );
-
- uFieldMask &= ~ osl_FileStatus_Mask_Validate;
- }
-
- /* If no fields to retrieve left ignore pStatus */
- if ( !uFieldMask )
- return osl_File_E_None;
-
- /* Otherwise, this must be a valid pointer */
- if ( !pStatus )
- return osl_File_E_INVAL;
-
- if ( pStatus->uStructSize != sizeof(oslFileStatus) )
- return osl_File_E_INVAL;
-
- pStatus->uValidFields = 0;
-
- /* File time stamps */
-
- if ( (uFieldMask & osl_FileStatus_Mask_ModifyTime) &&
- FileTimeToTimeValue( &pItemImpl->FindData.ftLastWriteTime, &pStatus->aModifyTime ) )
- pStatus->uValidFields |= osl_FileStatus_Mask_ModifyTime;
-
- if ( (uFieldMask & osl_FileStatus_Mask_AccessTime) &&
- FileTimeToTimeValue( &pItemImpl->FindData.ftLastAccessTime, &pStatus->aAccessTime ) )
- pStatus->uValidFields |= osl_FileStatus_Mask_AccessTime;
-
- if ( (uFieldMask & osl_FileStatus_Mask_CreationTime) &&
- FileTimeToTimeValue( &pItemImpl->FindData.ftCreationTime, &pStatus->aCreationTime ) )
- pStatus->uValidFields |= osl_FileStatus_Mask_CreationTime;
-
- /* Most of the fields are already set, regardless of requiered fields */
-
- rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(pItemImpl->FindData.cFileName) );
- pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
-
- if ((FILE_ATTRIBUTE_REPARSE_POINT & pItemImpl->FindData.dwFileAttributes) &&
- (IO_REPARSE_TAG_MOUNT_POINT == pItemImpl->FindData.dwReserved0))
- pStatus->eType = osl_File_Type_Volume;
- else if (pItemImpl->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- pStatus->eType = osl_File_Type_Directory;
- else
- pStatus->eType = osl_File_Type_Regular;
-
- pStatus->uValidFields |= osl_FileStatus_Mask_Type;
-
- pStatus->uAttributes = pItemImpl->FindData.dwFileAttributes;
- pStatus->uValidFields |= osl_FileStatus_Mask_Attributes;
-
- pStatus->uFileSize = (sal_uInt64)pItemImpl->FindData.nFileSizeLow + ((sal_uInt64)pItemImpl->FindData.nFileSizeHigh << 32);
- pStatus->uValidFields |= osl_FileStatus_Mask_FileSize;
-
- if ( uFieldMask & osl_FileStatus_Mask_LinkTargetURL )
- {
- rtl_uString *ustrFullPath = NULL;
-
- rtl_uString_newFromStr( &ustrFullPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) );
- osl_getFileURLFromSystemPath( ustrFullPath, &pStatus->ustrLinkTargetURL );
- rtl_uString_release( ustrFullPath );
+ static sal_uInt64 const g_limit_longlong = std::numeric_limits< LONGLONG >::max();
+ if (g_limit_longlong < uSize)
+ return osl_File_E_OVERFLOW;
- pStatus->uValidFields |= osl_FileStatus_Mask_LinkTargetURL;
- }
+ oslFileError result = pImpl->syncFile();
+ if (result != osl_File_E_None)
+ return (result);
- if ( uFieldMask & osl_FileStatus_Mask_FileURL )
- {
- rtl_uString *ustrFullPath = NULL;
+ LARGE_INTEGER nDstPos; nDstPos.QuadPart = sal::static_int_cast< LONGLONG >(uSize);
+ if (!::SetFilePointerEx(pImpl->m_hFile, nDstPos, 0, FILE_BEGIN))
+ return oslTranslateFileError( GetLastError() );
+ if (!::SetEndOfFile(pImpl->m_hFile))
+ return oslTranslateFileError( GetLastError() );
+ pImpl->m_size = uSize;
- if ( !pItemImpl->bFullPathNormalized )
- {
- GetCaseCorrectPathName( pItemImpl->szFullPath, pItemImpl->szFullPath, sizeof(pItemImpl->szFullPath) );
- pItemImpl->bFullPathNormalized = TRUE;
- }
- rtl_uString_newFromStr( &ustrFullPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) );
- osl_getFileURLFromSystemPath( ustrFullPath, &pStatus->ustrFileURL );
- rtl_uString_release( ustrFullPath );
- pStatus->uValidFields |= osl_FileStatus_Mask_FileURL;
- }
+ nDstPos.QuadPart = pImpl->m_offset;
+ if (!::SetFilePointerEx(pImpl->m_hFile, nDstPos, 0, FILE_BEGIN))
+ return oslTranslateFileError( GetLastError() );
return osl_File_E_None;
}
//##################################################################
-// directory handling functions
+// File handling functions
//##################################################################
-
-//#####################################################
-oslFileError SAL_CALL osl_createDirectory(rtl_uString* strPath)
+//#############################################
+oslFileError SAL_CALL osl_removeFile( rtl_uString* strPath )
{
rtl_uString *strSysPath = NULL;
oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
if ( osl_File_E_None == error )
{
- if ( CreateDirectoryW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strSysPath )), NULL ) )
+ if ( DeleteFile( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )) ) )
error = osl_File_E_None;
-/*@@@ToDo
- The else case is a hack because the ucb or the webtop had some
- problems with the error code that CreateDirectory returns in
- case the path is only a logical drive, should be removed!
-*/
else
- {
- const sal_Unicode *pBuffer = rtl_uString_getStr( strSysPath );
- sal_Int32 nLen = rtl_uString_getLength( strSysPath );
-
- if (
- ( pBuffer[0] >= 'A' && pBuffer[0] <= 'Z' ||
- pBuffer[0] >= 'a' && pBuffer[0] <= 'z' ) &&
- pBuffer[1] == ':' && ( nLen ==2 || nLen == 3 && pBuffer[2] == '\\' )
- )
- SetLastError( ERROR_ALREADY_EXISTS );
-
- error = MapError( GetLastError() );
- }
+ error = oslTranslateFileError( GetLastError() );
rtl_uString_release( strSysPath );
}
return error;
}
-//#####################################################
-oslFileError SAL_CALL osl_removeDirectory(rtl_uString* strPath)
+//#############################################
+#define osl_File_CopyRecursive 0x0001
+#define osl_File_CopyOverwrite 0x0002
+
+oslFileError SAL_CALL osl_copyFile( rtl_uString* strPath, rtl_uString *strDestPath )
{
- rtl_uString *strSysPath = NULL;
+ rtl_uString *strSysPath = NULL, *strSysDestPath = NULL;
oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
if ( osl_File_E_None == error )
- {
- if ( RemoveDirectory( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )) ) )
- error = osl_File_E_None;
- else
- error = MapError( GetLastError() );
-
- rtl_uString_release( strSysPath );
- }
- return error;
-}
-
-//#####################################################
-oslFileError SAL_CALL osl_openDirectory(rtl_uString *strDirectoryPath, oslDirectory *pDirectory)
-{
- oslFileError error;
+ error = _osl_getSystemPathFromFileURL( strDestPath, &strSysDestPath, sal_False );
- if ( 0 == rtl_ustr_ascii_compareIgnoreAsciiCase( strDirectoryPath->buffer, "file:///" ) )
- error = osl_openLocalRoot( strDirectoryPath, pDirectory );
- else
+ if ( osl_File_E_None == error )
{
- rtl_uString *strSysDirectoryPath = NULL;
-// WCHAR szCorrectedPathName[MAX_PATH];
- DWORD dwPathType;
-
- error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysDirectoryPath, sal_False );
+ LPCTSTR src = reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath ));
+ LPCTSTR dst = reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysDestPath ));
- if ( osl_File_E_None != error )
- return error;
-
- // MT Perform05
- /*
- if ( GetCaseCorrectPathName( strSysDirectoryPath->buffer, szCorrectedPathName, MAX_PATH ) )
- {
- rtl_uString_newFromStr( &strSysDirectoryPath, szCorrectedPathName );
- }
- */
-
- dwPathType = IsValidFilePath( strSysDirectoryPath, NULL, VALIDATEPATH_NORMAL, NULL );
-
- if ( dwPathType & PATHTYPE_IS_SERVER )
- {
- error = osl_openNetworkServer( strSysDirectoryPath, pDirectory );
- }
+ if ( CopyFile( src, dst, FALSE ) )
+ error = osl_File_E_None;
else
- error = osl_openFileDirectory( strSysDirectoryPath, pDirectory );
-
- rtl_uString_release( strSysDirectoryPath );
- }
- return error;
-}
-
-//#####################################################
-oslFileError SAL_CALL osl_getNextDirectoryItem(oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint)
-{
- Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
-
- /* Assume failure */
-
- if ( !pItem )
- return osl_File_E_INVAL;
-
- *pItem = NULL;
-
- if ( !pDirImpl )
- return osl_File_E_INVAL;
-
- switch ( pDirImpl->uType )
- {
- case DIRECTORYTYPE_LOCALROOT:
- return osl_getNextDrive( Directory, pItem, uHint );
- case DIRECTORYTYPE_NETROOT:
- return osl_getNextNetResource( Directory, pItem, uHint );
- case DIRECTORYTYPE_FILESYSTEM:
- return osl_getNextFileItem( Directory, pItem, uHint );
- default:
- return osl_File_E_INVAL;
- }
-}
-
-//#####################################################
-oslFileError SAL_CALL osl_closeDirectory(oslDirectory Directory)
-{
- Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
- oslFileError eError = osl_File_E_INVAL;
-
- if ( pDirImpl )
- {
- switch ( pDirImpl->uType )
- {
- case DIRECTORYTYPE_FILESYSTEM:
- eError = CloseDirectory( pDirImpl->hDirectory ) ? osl_File_E_None : MapError( GetLastError() );
- break;
- case DIRECTORYTYPE_LOCALROOT:
- eError = CloseLogicalDrivesEnum( pDirImpl->hEnumDrives ) ? osl_File_E_None : MapError( GetLastError() );
- break;
- case DIRECTORYTYPE_NETROOT:
- {
- DWORD err = WNetCloseEnum(pDirImpl->hDirectory);
- eError = (err == NO_ERROR) ? osl_File_E_None : MapError(err);
- }
- break;
- default:
- OSL_ENSURE( 0, "Invalid directory type" );
- break;
- }
-
- rtl_freeMemory(pDirImpl);
- }
- return eError;
-}
-
-//#####################################################
-oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirectoryItem *pItem)
-{
- oslFileError error = osl_File_E_None;
- rtl_uString* strSysFilePath = NULL;
- PATHTYPE type = PATHTYPE_FILE;
- DWORD dwPathType;
-// TCHAR szCorrectedPathName[MAX_PATH];
-
- /* Assume failure */
-
- if ( !pItem )
- return osl_File_E_INVAL;
-
- *pItem = NULL;
-
-
- error = _osl_getSystemPathFromFileURL( strFilePath, &strSysFilePath, sal_False );
-
- if ( osl_File_E_None != error )
- return error;
-
- // MT: I can't imagine a case where this is good for!
- /*
- if ( GetCaseCorrectPathName( strSysFilePath->buffer, szCorrectedPathName, MAX_PATH ) )
- {
- rtl_uString_newFromStr( &strSysFilePath, szCorrectedPathName );
- }
- */
-
- dwPathType = IsValidFilePath( strSysFilePath, NULL, VALIDATEPATH_NORMAL, NULL );
-
- if ( dwPathType & PATHTYPE_IS_VOLUME )
- type = PATHTYPE_VOLUME;
- else if ( dwPathType & PATHTYPE_IS_SERVER )
- type = PATHTYPE_NETSERVER;
- else
- type = PATHTYPE_FILE;
-
- switch ( type )
- {
- case PATHTYPE_NETSERVER:
- {
- DirectoryItem_Impl* pItemImpl =
- reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
-
- if ( !pItemImpl )
- error = osl_File_E_NOMEM;
-
- if ( osl_File_E_None == error )
- {
- ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
- pItemImpl->uType = DIRECTORYITEM_SERVER;
-
- osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
-
- _tcscpy( pItemImpl->szFullPath, reinterpret_cast<LPCTSTR>(strSysFilePath->buffer) );
-
- // Assign a title anyway
- {
- int iSrc = 2;
- int iDst = 0;
-
- while( iSrc < strSysFilePath->length && strSysFilePath->buffer[iSrc] && strSysFilePath->buffer[iSrc] != '\\' )
- {
- pItemImpl->FindData.cFileName[iDst++] = strSysFilePath->buffer[iSrc++];
- }
- }
-
- *pItem = pItemImpl;
- }
- }
- break;
- case PATHTYPE_VOLUME:
- {
- DirectoryItem_Impl* pItemImpl =
- reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
-
- if ( !pItemImpl )
- error = osl_File_E_NOMEM;
-
- if ( osl_File_E_None == error )
- {
- ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
- pItemImpl->uType = DIRECTORYITEM_DRIVE;
-
- osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
-
- _tcscpy( pItemImpl->cDriveString, reinterpret_cast<LPCTSTR>(strSysFilePath->buffer) );
- pItemImpl->cDriveString[0] = _toupper( pItemImpl->cDriveString[0] );
-
- if ( pItemImpl->cDriveString[_tcslen(pItemImpl->cDriveString) - 1] != '\\' )
- _tcscat( pItemImpl->cDriveString, TEXT( "\\" ) );
-
- *pItem = pItemImpl;
- }
- }
- break;
- case PATHTYPE_SYNTAXERROR:
- case PATHTYPE_NETROOT:
- case PATHTYPE_FILE:
- {
- HANDLE hFind;
- WIN32_FIND_DATA aFindData;
-
- if ( strSysFilePath->length > 0 && strSysFilePath->buffer[strSysFilePath->length - 1] == '\\' )
- rtl_uString_newFromStr_WithLength( &strSysFilePath, strSysFilePath->buffer, strSysFilePath->length - 1 );
-
- hFind = FindFirstFile( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysFilePath)), &aFindData );
-
- if ( hFind != INVALID_HANDLE_VALUE )
- {
- DirectoryItem_Impl *pItemImpl =
- reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
-
- ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
- osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
-
- CopyMemory( &pItemImpl->FindData, &aFindData, sizeof(WIN32_FIND_DATA) );
- _tcscpy( pItemImpl->szFullPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysFilePath)) );
-
- // MT: This costs 600ms startup time on fast v60x!
- // GetCaseCorrectPathName( pItemImpl->szFullPath, pItemImpl->szFullPath, sizeof(pItemImpl->szFullPath) );
-
- pItemImpl->uType = DIRECTORYITEM_FILE;
- *pItem = pItemImpl;
- FindClose( hFind );
- }
- else
- error = MapError( GetLastError() );
- }
- break;
+ error = oslTranslateFileError( GetLastError() );
}
- if ( strSysFilePath )
- rtl_uString_release( strSysFilePath );
+ if ( strSysPath )
+ rtl_uString_release( strSysPath );
+ if ( strSysDestPath )
+ rtl_uString_release( strSysDestPath );
return error;
}
-//#####################################################
-oslFileError SAL_CALL osl_acquireDirectoryItem( oslDirectoryItem Item )
-{
- DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
-
- if ( !pItemImpl )
- return osl_File_E_INVAL;
-
- pItemImpl->nRefCount++;
- return osl_File_E_None;
-}
-
-//#####################################################
-oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item )
-{
- DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
-
- if ( !pItemImpl )
- return osl_File_E_INVAL;
-
- if ( ! --pItemImpl->nRefCount )
- rtl_freeMemory( pItemImpl );
- return osl_File_E_None;
-}
-
-//#####################################################
-oslFileError SAL_CALL osl_unmountVolumeDevice( oslVolumeDeviceHandle Handle )
-{
- if ( Handle )
- return osl_File_E_None;
- else
- return osl_File_E_INVAL;
-}
-
-//#####################################################
-oslFileError SAL_CALL osl_automountVolumeDevice( oslVolumeDeviceHandle Handle )
-{
- if ( Handle )
- return osl_File_E_None;
- else
- return osl_File_E_INVAL;
-}
-
-//#####################################################
-oslFileError SAL_CALL osl_acquireVolumeDeviceHandle( oslVolumeDeviceHandle Handle )
-{
- if ( Handle )
- {
- rtl_uString_acquire( (rtl_uString *)Handle );
- return osl_File_E_None;
- }
- else
- return osl_File_E_INVAL;
-}
-
-//#####################################################
-oslFileError SAL_CALL osl_releaseVolumeDeviceHandle( oslVolumeDeviceHandle Handle )
-{
- if ( Handle )
- {
- rtl_uString_release( (rtl_uString *)Handle );
- return osl_File_E_None;
- }
- else
- return osl_File_E_INVAL;
-}
-
-//#####################################################
-oslFileError SAL_CALL osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uString **pstrPath )
-{
- if ( Handle && pstrPath )
- {
- rtl_uString_assign( pstrPath, (rtl_uString *)Handle );
- return osl_File_E_None;
- }
- else
- return osl_File_E_INVAL;
-}
-
-
-//##################################################################
-// FileURL functions
-//##################################################################
-
-
-//#####################################################
-oslFileError SAL_CALL osl_getFileURLFromSystemPath(
- rtl_uString* ustrPath, rtl_uString** pustrURL )
-{
- return _osl_getFileURLFromSystemPath( ustrPath, pustrURL );
-}
-
-//#####################################################
-oslFileError SAL_CALL osl_getSystemPathFromFileURL(
- rtl_uString *ustrURL, rtl_uString **pustrPath)
-{
- return _osl_getSystemPathFromFileURL( ustrURL, pustrPath, sal_True );
-}
-
-//#####################################################
-oslFileError SAL_CALL osl_searchFileURL(
- rtl_uString *ustrFileName,
- rtl_uString *ustrSystemSearchPath,
- rtl_uString **pustrPath)
+//#############################################
+oslFileError SAL_CALL osl_moveFile( rtl_uString* strPath, rtl_uString *strDestPath )
{
- rtl_uString *ustrUNCPath = NULL;
- rtl_uString *ustrSysPath = NULL;
- oslFileError error;
-
- /* First try to interpret the file name as an URL even a relative one */
- error = _osl_getSystemPathFromFileURL( ustrFileName, &ustrUNCPath, sal_True );
+ rtl_uString *strSysPath = NULL, *strSysDestPath = NULL;
+ oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
- /* So far we either have an UNC path or something invalid
- Now create a system path */
if ( osl_File_E_None == error )
- error = _osl_getSystemPathFromFileURL( ustrUNCPath, &ustrSysPath, sal_True );
+ error = _osl_getSystemPathFromFileURL( strDestPath, &strSysDestPath, sal_False );
if ( osl_File_E_None == error )
{
- DWORD nBufferLength;
- DWORD dwResult;
- LPTSTR lpBuffer = NULL;
- LPTSTR lpszFilePart;
+ LPCTSTR src = reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath ));
+ LPCTSTR dst = reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysDestPath ));
- /* Repeat calling SearchPath ...
- Start with MAX_PATH for the buffer. In most cases this
- will be enough and does not force the loop to runtwice */
- dwResult = MAX_PATH;
-
- do
- {
- /* If search path is empty use a NULL pointer instead according to MSDN documentation of SearchPath */
- LPCTSTR lpszSearchPath = ustrSystemSearchPath && ustrSystemSearchPath->length ? reinterpret_cast<LPCTSTR>(ustrSystemSearchPath->buffer) : NULL;
- LPCTSTR lpszSearchFile = reinterpret_cast<LPCTSTR>(ustrSysPath->buffer);
-
- /* Allocate space for buffer according to previous returned count of required chars */
- /* +1 is not neccessary if we follow MSDN documentation but for robustness we do so */
- nBufferLength = dwResult + 1;
- lpBuffer = lpBuffer ?
- reinterpret_cast<LPTSTR>(rtl_reallocateMemory(lpBuffer, nBufferLength * sizeof(TCHAR))) :
- reinterpret_cast<LPTSTR>(rtl_allocateMemory(nBufferLength * sizeof(TCHAR)));
-
- dwResult = SearchPath( lpszSearchPath, lpszSearchFile, NULL, nBufferLength, lpBuffer, &lpszFilePart );
- } while ( dwResult && dwResult >= nBufferLength );
-
- /* ... until an error occures or buffer is large enough.
- dwResult == nBufferLength can not happen according to documentation but lets be robust ;-) */
-
- if ( dwResult )
- {
- rtl_uString_newFromStr( &ustrSysPath, reinterpret_cast<const sal_Unicode*>(lpBuffer) );
- error = osl_getFileURLFromSystemPath( ustrSysPath, pustrPath );
- }
+ if ( MoveFileEx( src, dst, MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH | MOVEFILE_REPLACE_EXISTING ) )
+ error = osl_File_E_None;
else
- {
- WIN32_FIND_DATA aFindFileData;
- HANDLE hFind;
-
- /* Somthing went wrong, perhaps the path was absolute */
- error = MapError( GetLastError() );
-
- hFind = FindFirstFile( reinterpret_cast<LPCTSTR>(ustrSysPath->buffer), &aFindFileData );
-
- if ( IsValidHandle(hFind) )
- {
- error = osl_getFileURLFromSystemPath( ustrSysPath, pustrPath );
- FindClose( hFind );
- }
- }
-
- rtl_freeMemory( lpBuffer );
+ error = oslTranslateFileError( GetLastError() );
}
- if ( ustrSysPath )
- rtl_uString_release( ustrSysPath );
-
- if ( ustrUNCPath )
- rtl_uString_release( ustrUNCPath );
+ if ( strSysPath )
+ rtl_uString_release( strSysPath );
+ if ( strSysDestPath )
+ rtl_uString_release( strSysDestPath );
return error;
}
-
-//#####################################################
-
-oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uString* ustrRelativeURL, rtl_uString** pustrAbsoluteURL )
-{
- oslFileError eError;
- rtl_uString *ustrRelSysPath = NULL;
- rtl_uString *ustrBaseSysPath = NULL;
-
- if ( ustrBaseURL && ustrBaseURL->length )
- {
- eError = _osl_getSystemPathFromFileURL( ustrBaseURL, &ustrBaseSysPath, sal_False );
- OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called with relative or invalid base URL" );
-
- eError = _osl_getSystemPathFromFileURL( ustrRelativeURL, &ustrRelSysPath, sal_True );
- }
- else
- {
- eError = _osl_getSystemPathFromFileURL( ustrRelativeURL, &ustrRelSysPath, sal_False );
- OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called with empty base URL and/or invalid relative URL" );
- }
-
- if ( !eError )
- {
- TCHAR szBuffer[MAX_PATH];
- TCHAR szCurrentDir[MAX_PATH];
- LPTSTR lpFilePart = NULL;
- DWORD dwResult;
-
-/*@@@ToDo
- Bad, bad hack, this only works if the base path
- really exists which is not necessary according
- to RFC2396
- The whole FileURL implementation should be merged
- with the rtl/uri class.
-*/
- if ( ustrBaseSysPath )
- {
- osl_acquireMutex( g_CurrentDirectoryMutex );
-
- GetCurrentDirectory( MAX_PATH, szCurrentDir );
- SetCurrentDirectory( reinterpret_cast<LPCTSTR>(ustrBaseSysPath->buffer) );
- }
-
- dwResult = GetFullPathName( reinterpret_cast<LPCTSTR>(ustrRelSysPath->buffer), MAX_PATH, szBuffer, &lpFilePart );
-
- if ( ustrBaseSysPath )
- {
- SetCurrentDirectory( szCurrentDir );
-
- osl_releaseMutex( g_CurrentDirectoryMutex );
- }
-
- if ( dwResult )
- {
- if ( dwResult >= MAX_PATH )
- eError = osl_File_E_INVAL;
- else
- {
- rtl_uString *ustrAbsSysPath = NULL;
-
- rtl_uString_newFromStr( &ustrAbsSysPath, reinterpret_cast<const sal_Unicode*>(szBuffer) );
-
- eError = osl_getFileURLFromSystemPath( ustrAbsSysPath, pustrAbsoluteURL );
-
- if ( ustrAbsSysPath )
- rtl_uString_release( ustrAbsSysPath );
- }
- }
- else
- eError = MapError( GetLastError() );
- }
-
- if ( ustrBaseSysPath )
- rtl_uString_release( ustrBaseSysPath );
-
- if ( ustrRelSysPath )
- rtl_uString_release( ustrRelSysPath );
-
- return eError;
-}
-
-//#####################################################
-oslFileError SAL_CALL osl_getCanonicalName( rtl_uString *strRequested, rtl_uString **strValid )
-{
- rtl_uString_newFromString(strValid, strRequested);
- return osl_File_E_None;
-}
diff --git a/sal/osl/w32/file_dirvol.cxx b/sal/osl/w32/file_dirvol.cxx
new file mode 100644
index 000000000000..5ea839ae215d
--- /dev/null
+++ b/sal/osl/w32/file_dirvol.cxx
@@ -0,0 +1,1777 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: file.cxx,v $
+ * $Revision: 1.19 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define UNICODE
+#define _UNICODE
+#define _WIN32_WINNT_0x0500
+#include "systools/win32/uwinapi.h"
+
+#include "osl/file.h"
+
+#include "file_url.h"
+#include "file_error.h"
+#include "path_helper.hxx"
+
+#include "osl/diagnose.h"
+#include "osl/time.h"
+#include "rtl/alloc.h"
+#include "rtl/ustring.hxx"
+
+#include <tchar.h>
+#ifdef __MINGW32__
+#include <ctype.h>
+#endif
+
+//#####################################################
+#define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0])))
+
+static const wchar_t UNC_PREFIX[] = L"\\\\";
+static const wchar_t BACKSLASH = '\\';
+static const wchar_t SLASH = '/';
+
+//#####################################################
+extern "C" BOOL TimeValueToFileTime(const TimeValue *cpTimeVal, FILETIME *pFTime)
+{
+ SYSTEMTIME BaseSysTime;
+ FILETIME BaseFileTime;
+ FILETIME FTime;
+ __int64 localTime;
+ BOOL fSuccess = FALSE;
+
+ BaseSysTime.wYear = 1970;
+ BaseSysTime.wMonth = 1;
+ BaseSysTime.wDayOfWeek = 0;
+ BaseSysTime.wDay = 1;
+ BaseSysTime.wHour = 0;
+ BaseSysTime.wMinute = 0;
+ BaseSysTime.wSecond = 0;
+ BaseSysTime.wMilliseconds = 0;
+
+ if (cpTimeVal==NULL)
+ return fSuccess;
+
+ if ( SystemTimeToFileTime(&BaseSysTime, &BaseFileTime) )
+ {
+ __int64 timeValue;
+ localTime=cpTimeVal->Seconds*(__int64)10000000+cpTimeVal->Nanosec/100;
+ *(__int64 *)&FTime=localTime;
+ fSuccess = 0 <= (timeValue= *((__int64 *)&BaseFileTime) + *((__int64 *) &FTime));
+ if (fSuccess)
+ *(__int64 *)pFTime=timeValue;
+ }
+ return fSuccess;
+}
+
+//#####################################################
+extern "C" BOOL FileTimeToTimeValue(const FILETIME *cpFTime, TimeValue *pTimeVal)
+{
+ SYSTEMTIME BaseSysTime;
+ FILETIME BaseFileTime;
+ BOOL fSuccess = FALSE; /* Assume failure */
+
+ BaseSysTime.wYear = 1970;
+ BaseSysTime.wMonth = 1;
+ BaseSysTime.wDayOfWeek = 0;
+ BaseSysTime.wDay = 1;
+ BaseSysTime.wHour = 0;
+ BaseSysTime.wMinute = 0;
+ BaseSysTime.wSecond = 0;
+ BaseSysTime.wMilliseconds = 0;
+
+ if ( SystemTimeToFileTime(&BaseSysTime, &BaseFileTime) )
+ {
+ __int64 Value;
+
+ fSuccess = 0 <= (Value = *((__int64 *)cpFTime) - *((__int64 *)&BaseFileTime));
+
+ if ( fSuccess )
+ {
+ pTimeVal->Seconds = (unsigned long) (Value / 10000000L);
+ pTimeVal->Nanosec = (unsigned long)((Value % 10000000L) * 100);
+ }
+ }
+ return fSuccess;
+}
+
+//#####################################################
+namespace /* private */
+{
+ //#####################################################
+ struct Component
+ {
+ Component() :
+ begin_(0), end_(0)
+ {}
+
+ bool isPresent() const
+ { return (static_cast<sal_IntPtr>(end_ - begin_) > 0); }
+
+ const sal_Unicode* begin_;
+ const sal_Unicode* end_;
+ };
+
+ //#####################################################
+ struct UNCComponents
+ {
+ Component server_;
+ Component share_;
+ Component resource_;
+ };
+
+ //#####################################################
+ inline bool is_UNC_path(const sal_Unicode* path)
+ { return (0 == wcsncmp(UNC_PREFIX, reinterpret_cast<LPCWSTR>(path), ELEMENTS_OF_ARRAY(UNC_PREFIX) - 1)); }
+
+ //#####################################################
+ inline bool is_UNC_path(const rtl::OUString& path)
+ { return is_UNC_path(path.getStr()); }
+
+ //#####################################################
+ void parse_UNC_path(const sal_Unicode* path, UNCComponents* puncc)
+ {
+ OSL_PRECOND(is_UNC_path(path), "Precondition violated: No UNC path");
+ OSL_PRECOND(rtl_ustr_indexOfChar(path, SLASH) != -1, "Path must not contain slashes");
+
+ const sal_Unicode* pend = path + rtl_ustr_getLength(path);
+ const sal_Unicode* ppos = path + 2;
+
+ puncc->server_.begin_ = ppos;
+ while ((ppos < pend) && (*ppos != BACKSLASH))
+ ppos++;
+
+ puncc->server_.end_ = ppos;
+
+ if (BACKSLASH == *ppos)
+ {
+ puncc->share_.begin_ = ++ppos;
+ while ((ppos < pend) && (*ppos != BACKSLASH))
+ ppos++;
+
+ puncc->share_.end_ = ppos;
+
+ if (BACKSLASH == *ppos)
+ {
+ puncc->resource_.begin_ = ++ppos;
+ while (ppos < pend)
+ ppos++;
+
+ puncc->resource_.end_ = ppos;
+ }
+ }
+
+ OSL_POSTCOND(puncc->server_.isPresent() && puncc->share_.isPresent(), \
+ "Postcondition violated: Invalid UNC path detected");
+ }
+
+ //#####################################################
+ void parse_UNC_path(const rtl::OUString& path, UNCComponents* puncc)
+ { parse_UNC_path(path.getStr(), puncc); }
+
+
+ //#####################################################
+ bool has_path_parent(const sal_Unicode* path)
+ {
+ // Has the given path a parent or are we already there,
+ // e.g. 'c:\' or '\\server\share\'?
+
+ bool has_parent = false;
+ if (is_UNC_path(path))
+ {
+ UNCComponents unc_comp;
+ parse_UNC_path(path, &unc_comp);
+ has_parent = unc_comp.resource_.isPresent();
+ }
+ else
+ {
+ has_parent = !osl::systemPathIsLogicalDrivePattern(path);
+ }
+ return has_parent;
+ }
+
+ //#####################################################
+ inline bool has_path_parent(const rtl::OUString& path)
+ { return has_path_parent(path.getStr()); }
+
+} // end namespace private
+
+//#####################################################
+// volume handling functions
+//#####################################################
+
+//#####################################################
+oslFileError SAL_CALL osl_unmountVolumeDevice( oslVolumeDeviceHandle Handle )
+{
+ if ( Handle )
+ return osl_File_E_None;
+ else
+ return osl_File_E_INVAL;
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_automountVolumeDevice( oslVolumeDeviceHandle Handle )
+{
+ if ( Handle )
+ return osl_File_E_None;
+ else
+ return osl_File_E_INVAL;
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_acquireVolumeDeviceHandle( oslVolumeDeviceHandle Handle )
+{
+ if ( Handle )
+ {
+ rtl_uString_acquire( (rtl_uString *)Handle );
+ return osl_File_E_None;
+ }
+ else
+ return osl_File_E_INVAL;
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_releaseVolumeDeviceHandle( oslVolumeDeviceHandle Handle )
+{
+ if ( Handle )
+ {
+ rtl_uString_release( (rtl_uString *)Handle );
+ return osl_File_E_None;
+ }
+ else
+ return osl_File_E_INVAL;
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_getVolumeDeviceMountPath( oslVolumeDeviceHandle Handle, rtl_uString **pstrPath )
+{
+ if ( Handle && pstrPath )
+ {
+ rtl_uString_assign( pstrPath, (rtl_uString *)Handle );
+ return osl_File_E_None;
+ }
+ else
+ return osl_File_E_INVAL;
+}
+
+//##################################################################
+// directory handling functions
+//##################################################################
+
+#define DIRECTORYITEM_DRIVE 0
+#define DIRECTORYITEM_FILE 1
+#define DIRECTORYITEM_SERVER 2
+
+struct DirectoryItem_Impl
+{
+ UINT uType;
+ union {
+ WIN32_FIND_DATA FindData;
+ TCHAR cDriveString[MAX_PATH];
+ };
+ TCHAR szFullPath[MAX_PATH];
+ BOOL bFullPathNormalized;
+ int nRefCount;
+};
+
+//#####################################################
+
+#define DIRECTORYTYPE_LOCALROOT 0
+#define DIRECTORYTYPE_NETROOT 1
+#define DIRECTORYTYPE_NETRESORCE 2
+#define DIRECTORYTYPE_FILESYSTEM 3
+
+struct Directory_Impl
+{
+ UINT uType;
+ union {
+ HANDLE hDirectory;
+ HANDLE hEnumDrives;
+ };
+ TCHAR szDirectoryPath[MAX_PATH];
+};
+
+//#####################################################
+
+typedef struct tagDRIVEENUM
+{
+ LPCTSTR lpIdent;
+ TCHAR cBuffer[/*('Z' - 'A' + 1) * sizeof("A:\\") + 1*/256];
+ LPCTSTR lpCurrent;
+} DRIVEENUM, * PDRIVEENUM, FAR * LPDRIVEENUM;
+
+//#####################################################
+
+static HANDLE WINAPI OpenLogicalDrivesEnum(void)
+{
+ LPDRIVEENUM pEnum = (LPDRIVEENUM)HeapAlloc( GetProcessHeap(), 0, sizeof(DRIVEENUM) );
+ if ( pEnum )
+ {
+ DWORD dwNumCopied = GetLogicalDriveStrings( (sizeof(pEnum->cBuffer) - 1) / sizeof(TCHAR), pEnum->cBuffer );
+
+ if ( dwNumCopied && dwNumCopied < sizeof(pEnum->cBuffer) / sizeof(TCHAR) )
+ {
+ pEnum->lpCurrent = pEnum->cBuffer;
+ pEnum->lpIdent = L"tagDRIVEENUM";
+ }
+ else
+ {
+ HeapFree( GetProcessHeap(), 0, pEnum );
+ pEnum = NULL;
+ }
+ }
+ return pEnum ? (HANDLE)pEnum : INVALID_HANDLE_VALUE;
+}
+
+//#####################################################
+static BOOL WINAPI EnumLogicalDrives(HANDLE hEnum, LPTSTR lpBuffer)
+{
+ BOOL fSuccess = FALSE;
+ LPDRIVEENUM pEnum = (LPDRIVEENUM)hEnum;
+
+ if ( pEnum )
+ {
+ int nLen = _tcslen( pEnum->lpCurrent );
+
+ if ( nLen )
+ {
+ CopyMemory( lpBuffer, pEnum->lpCurrent, (nLen + 1) * sizeof(TCHAR) );
+ pEnum->lpCurrent += nLen + 1;
+ fSuccess = TRUE;
+ }
+ else
+ SetLastError( ERROR_NO_MORE_FILES );
+ }
+ else
+ SetLastError( ERROR_INVALID_HANDLE );
+
+ return fSuccess;
+}
+
+//#####################################################
+static BOOL WINAPI CloseLogicalDrivesEnum(HANDLE hEnum)
+{
+ BOOL fSuccess = FALSE;
+ LPDRIVEENUM pEnum = (LPDRIVEENUM)hEnum;
+
+ if ( pEnum )
+ {
+ HeapFree( GetProcessHeap(), 0, pEnum );
+ fSuccess = TRUE;
+ }
+ else
+ SetLastError( ERROR_INVALID_HANDLE );
+
+ return fSuccess;
+}
+
+//#####################################################
+typedef struct tagDIRECTORY
+{
+ HANDLE hFind;
+ WIN32_FIND_DATA aFirstData;
+} DIRECTORY, *PDIRECTORY, FAR *LPDIRECTORY;
+
+//#####################################################
+static HANDLE WINAPI OpenDirectory(LPCTSTR lpszPath)
+{
+ LPDIRECTORY pDirectory = (LPDIRECTORY)HeapAlloc(GetProcessHeap(), 0, sizeof(DIRECTORY));
+
+ if (pDirectory)
+ {
+ TCHAR szFileMask[MAX_PATH];
+ int nLen;
+
+ _tcscpy( szFileMask, lpszPath );
+ nLen = _tcslen( szFileMask );
+
+ if (nLen && szFileMask[nLen-1] != '\\')
+ _tcscat(szFileMask, TEXT("\\*.*"));
+ else
+ _tcscat(szFileMask, TEXT("*.*"));
+
+ pDirectory->hFind = FindFirstFile(szFileMask, &pDirectory->aFirstData);
+
+ if (!IsValidHandle(pDirectory->hFind))
+ {
+ if ( GetLastError() != ERROR_NO_MORE_FILES )
+ {
+ HeapFree(GetProcessHeap(), 0, pDirectory);
+ pDirectory = NULL;
+ }
+ }
+ }
+ return (HANDLE)pDirectory;
+}
+
+//#####################################################
+BOOL WINAPI EnumDirectory(HANDLE hDirectory, LPWIN32_FIND_DATA pFindData)
+{
+ BOOL fSuccess = FALSE;
+ LPDIRECTORY pDirectory = (LPDIRECTORY)hDirectory;
+
+ if ( pDirectory )
+ {
+ BOOL fValid;
+
+ do
+ {
+ if ( pDirectory->aFirstData.cFileName[0] )
+ {
+ *pFindData = pDirectory->aFirstData;
+ fSuccess = TRUE;
+ pDirectory->aFirstData.cFileName[0] = 0;
+ }
+ else if ( IsValidHandle( pDirectory->hFind ) )
+ fSuccess = FindNextFile( pDirectory->hFind, pFindData );
+ else
+ {
+ fSuccess = FALSE;
+ SetLastError( ERROR_NO_MORE_FILES );
+ }
+
+ fValid = fSuccess && _tcscmp( TEXT("."), pFindData->cFileName ) != 0 && _tcscmp( TEXT(".."), pFindData->cFileName ) != 0;
+
+ } while( fSuccess && !fValid );
+ }
+ else
+ SetLastError( ERROR_INVALID_HANDLE );
+
+ return fSuccess;
+}
+
+//#####################################################
+static BOOL WINAPI CloseDirectory(HANDLE hDirectory)
+{
+ BOOL fSuccess = FALSE;
+ LPDIRECTORY pDirectory = (LPDIRECTORY)hDirectory;
+
+ if (pDirectory)
+ {
+ if (IsValidHandle(pDirectory->hFind))
+ fSuccess = FindClose(pDirectory->hFind);
+
+ fSuccess = HeapFree(GetProcessHeap(), 0, pDirectory) && fSuccess;
+ }
+ else
+ SetLastError(ERROR_INVALID_HANDLE);
+
+ return fSuccess;
+}
+
+//#####################################################
+static oslFileError osl_openLocalRoot(
+ rtl_uString *strDirectoryPath, oslDirectory *pDirectory)
+{
+ rtl_uString *strSysPath = NULL;
+ oslFileError error;
+
+ if ( !pDirectory )
+ return osl_File_E_INVAL;
+
+ *pDirectory = NULL;
+
+ error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysPath, sal_False );
+ if ( osl_File_E_None == error )
+ {
+ Directory_Impl *pDirImpl;
+
+ pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory( sizeof(Directory_Impl)));
+ _tcscpy( pDirImpl->szDirectoryPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysPath)) );
+
+ /* Append backslash if neccessary */
+
+ /* @@@ToDo
+ use function ensure backslash
+ */
+ if ( pDirImpl->szDirectoryPath[_tcslen(pDirImpl->szDirectoryPath) - 1] != L'\\' )
+ _tcscat( pDirImpl->szDirectoryPath, L"\\" );
+
+ pDirImpl->uType = DIRECTORYTYPE_LOCALROOT;
+ pDirImpl->hEnumDrives = OpenLogicalDrivesEnum();
+
+ /* @@@ToDo
+ Use IsValidHandle(...)
+ */
+ if ( pDirImpl->hEnumDrives != INVALID_HANDLE_VALUE )
+ {
+ *pDirectory = (oslDirectory)pDirImpl;
+ error = osl_File_E_None;
+ }
+ else
+ {
+ if ( pDirImpl )
+ rtl_freeMemory(pDirImpl);
+
+ error = oslTranslateFileError( GetLastError() );
+ }
+
+ rtl_uString_release( strSysPath );
+ }
+ return error;
+}
+
+//#####################################################
+static oslFileError SAL_CALL osl_openFileDirectory(
+ rtl_uString *strDirectoryPath, oslDirectory *pDirectory)
+{
+ oslFileError error = osl_File_E_None;
+
+ if ( !pDirectory )
+ return osl_File_E_INVAL;
+ *pDirectory = NULL;
+
+ Directory_Impl *pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl)));
+ _tcscpy( pDirImpl->szDirectoryPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strDirectoryPath)) );
+
+ /* Append backslash if neccessary */
+
+ /* @@@ToDo
+ use function ensure backslash
+ */
+ if ( pDirImpl->szDirectoryPath[_tcslen(pDirImpl->szDirectoryPath) - 1] != L'\\' )
+ _tcscat( pDirImpl->szDirectoryPath, L"\\" );
+
+ pDirImpl->uType = DIRECTORYTYPE_FILESYSTEM;
+ pDirImpl->hDirectory = OpenDirectory( pDirImpl->szDirectoryPath );
+
+ if ( !pDirImpl->hDirectory )
+ {
+ error = oslTranslateFileError( GetLastError() );
+
+ rtl_freeMemory(pDirImpl), pDirImpl = 0;
+ }
+
+ *pDirectory = (oslDirectory)(pDirImpl);
+ return error;
+}
+
+//#####################################################
+static oslFileError SAL_CALL osl_openNetworkServer(
+ rtl_uString *strSysDirPath, oslDirectory *pDirectory)
+{
+ NETRESOURCEW aNetResource;
+ HANDLE hEnum;
+ DWORD dwError;
+
+ ZeroMemory( &aNetResource, sizeof(aNetResource) );
+
+ aNetResource.lpRemoteName = reinterpret_cast<LPWSTR>(strSysDirPath->buffer);
+
+ dwError = WNetOpenEnumW(
+ RESOURCE_GLOBALNET,
+ RESOURCETYPE_DISK,
+ RESOURCEUSAGE_CONNECTABLE | RESOURCEUSAGE_CONTAINER,
+ &aNetResource,
+ &hEnum );
+
+ if ( ERROR_SUCCESS == dwError )
+ {
+ Directory_Impl *pDirImpl;
+
+ pDirImpl = reinterpret_cast<Directory_Impl*>(rtl_allocateMemory(sizeof(Directory_Impl)));
+ pDirImpl->uType = DIRECTORYTYPE_NETROOT;
+ pDirImpl->hDirectory = hEnum;
+ *pDirectory = (oslDirectory)pDirImpl;
+ }
+ return oslTranslateFileError( dwError );
+}
+
+//#############################################
+static DWORD create_dir_with_callback(
+ rtl_uString * dir_path,
+ oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
+ void* pData)
+{
+ // Create the specified directory and call the
+ // user specified callback function. On success
+ // the function returns ERROR_SUCCESS else a Win32 error code.
+
+ if (CreateDirectory(reinterpret_cast<LPCTSTR>(dir_path->buffer), NULL))
+ {
+ if (aDirectoryCreationCallbackFunc)
+ {
+ rtl::OUString url;
+ _osl_getFileURLFromSystemPath(dir_path, &(url.pData));
+ aDirectoryCreationCallbackFunc(pData, url.pData);
+ }
+ return ERROR_SUCCESS;
+ }
+ return GetLastError();
+}
+
+//#############################################
+static int path_make_parent(sal_Unicode* path)
+{
+ /* Cut off the last part of the given path to
+ get the parent only, e.g. 'c:\dir\subdir' ->
+ 'c:\dir' or '\\share\sub\dir' -> '\\share\sub'
+ @return The position where the path has been cut
+ off (this is the posistion of the last backslash).
+ If there are no more parents 0 will be returned,
+ e.g. 'c:\' or '\\Share' have no more parents */
+
+ OSL_PRECOND(rtl_ustr_indexOfChar(path, SLASH) != -1, "Path must not contain slashes");
+ OSL_PRECOND(has_path_parent(path), "Path must have a parent");
+
+ sal_Unicode* pos_last_backslash = path + rtl_ustr_lastIndexOfChar(path, BACKSLASH);
+ *pos_last_backslash = 0;
+ return (pos_last_backslash - path);
+}
+
+//#############################################
+static DWORD create_dir_recursively_(
+ rtl_uString * dir_path,
+ oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
+ void* pData)
+{
+ OSL_PRECOND(
+ rtl_ustr_lastIndexOfChar_WithLength(dir_path->buffer, dir_path->length, BACKSLASH) != dir_path->length,
+ "Path must not end with a backslash");
+
+ DWORD w32_error = create_dir_with_callback(
+ dir_path, aDirectoryCreationCallbackFunc, pData);
+ if (w32_error == ERROR_SUCCESS)
+ return ERROR_SUCCESS;
+
+ if ((w32_error != ERROR_PATH_NOT_FOUND) || !has_path_parent(dir_path->buffer))
+ return w32_error;
+
+ int pos = path_make_parent(dir_path->buffer); // dir_path->buffer[pos] = 0, restore below
+
+ w32_error = create_dir_recursively_(
+ dir_path, aDirectoryCreationCallbackFunc, pData);
+
+ dir_path->buffer[pos] = BACKSLASH; // restore
+
+ if (ERROR_SUCCESS != w32_error)
+ return w32_error;
+
+ return create_dir_recursively_(dir_path, aDirectoryCreationCallbackFunc, pData);
+}
+
+//#############################################
+oslFileError SAL_CALL osl_createDirectoryPath(
+ rtl_uString* aDirectoryUrl,
+ oslDirectoryCreationCallbackFunc aDirectoryCreationCallbackFunc,
+ void* pData)
+{
+ if (aDirectoryUrl == NULL)
+ return osl_File_E_INVAL;
+
+ rtl::OUString sys_path;
+ oslFileError osl_error =
+ _osl_getSystemPathFromFileURL(aDirectoryUrl, &sys_path.pData, sal_False);
+
+ if (osl_error != osl_File_E_None)
+ return osl_error;
+
+ osl::systemPathRemoveSeparator(sys_path);
+
+ // const_cast because sys_path is a local copy
+ // which we want to modify inplace instead of
+ // coyp it into another buffer on the heap again
+ return oslTranslateFileError(create_dir_recursively_(
+ sys_path.pData, aDirectoryCreationCallbackFunc, pData));
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_createDirectory(rtl_uString* strPath)
+{
+ rtl_uString *strSysPath = NULL;
+ oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
+
+ if ( osl_File_E_None == error )
+ {
+ if ( CreateDirectoryW( reinterpret_cast<LPCWSTR>(rtl_uString_getStr( strSysPath )), NULL ) )
+ error = osl_File_E_None;
+/*@@@ToDo
+ The else case is a hack because the ucb or the webtop had some
+ problems with the error code that CreateDirectory returns in
+ case the path is only a logical drive, should be removed!
+*/
+ else
+ {
+ const sal_Unicode *pBuffer = rtl_uString_getStr( strSysPath );
+ sal_Int32 nLen = rtl_uString_getLength( strSysPath );
+
+ if (
+ ( ( pBuffer[0] >= 'A' && pBuffer[0] <= 'Z' ) ||
+ ( pBuffer[0] >= 'a' && pBuffer[0] <= 'z' ) ) &&
+ pBuffer[1] == ':' && ( nLen ==2 || ( nLen == 3 && pBuffer[2] == '\\' ) )
+ )
+ SetLastError( ERROR_ALREADY_EXISTS );
+
+ error = oslTranslateFileError( GetLastError() );
+ }
+
+ rtl_uString_release( strSysPath );
+ }
+ return error;
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_removeDirectory(rtl_uString* strPath)
+{
+ rtl_uString *strSysPath = NULL;
+ oslFileError error = _osl_getSystemPathFromFileURL( strPath, &strSysPath, sal_False );
+
+ if ( osl_File_E_None == error )
+ {
+ if ( RemoveDirectory( reinterpret_cast<LPCTSTR>(rtl_uString_getStr( strSysPath )) ) )
+ error = osl_File_E_None;
+ else
+ error = oslTranslateFileError( GetLastError() );
+
+ rtl_uString_release( strSysPath );
+ }
+ return error;
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_openDirectory(rtl_uString *strDirectoryPath, oslDirectory *pDirectory)
+{
+ oslFileError error;
+
+ if ( 0 == rtl_ustr_ascii_compareIgnoreAsciiCase( strDirectoryPath->buffer, "file:///" ) )
+ error = osl_openLocalRoot( strDirectoryPath, pDirectory );
+ else
+ {
+ rtl_uString *strSysDirectoryPath = NULL;
+ DWORD dwPathType;
+
+ error = _osl_getSystemPathFromFileURL( strDirectoryPath, &strSysDirectoryPath, sal_False );
+
+ if ( osl_File_E_None != error )
+ return error;
+
+ dwPathType = IsValidFilePath( strSysDirectoryPath, NULL, VALIDATEPATH_NORMAL, NULL );
+
+ if ( dwPathType & PATHTYPE_IS_SERVER )
+ {
+ error = osl_openNetworkServer( strSysDirectoryPath, pDirectory );
+ }
+ else
+ error = osl_openFileDirectory( strSysDirectoryPath, pDirectory );
+
+ rtl_uString_release( strSysDirectoryPath );
+ }
+ return error;
+}
+
+//#####################################################
+static oslFileError SAL_CALL osl_getNextNetResource(
+ oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint )
+{
+ Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
+ DirectoryItem_Impl *pItemImpl = NULL;
+ BYTE buffer[16384];
+ LPNETRESOURCEW lpNetResource = (LPNETRESOURCEW)buffer;
+ DWORD dwError, dwCount, dwBufSize;
+
+ uHint = uHint; /* to get no warning */
+
+ if ( !pItem )
+ return osl_File_E_INVAL;
+ *pItem = NULL;
+
+ if ( !pDirImpl )
+ return osl_File_E_INVAL;
+
+ dwCount = 1;
+ dwBufSize = sizeof(buffer);
+ dwError = WNetEnumResource( pDirImpl->hDirectory, &dwCount, lpNetResource, &dwBufSize );
+
+ switch ( dwError )
+ {
+ case NO_ERROR:
+ case ERROR_MORE_DATA:
+ {
+ pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
+ if ( !pItemImpl )
+ return osl_File_E_NOMEM;
+
+ ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
+ pItemImpl->uType = DIRECTORYITEM_DRIVE;
+ osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
+
+ wcscpy( pItemImpl->cDriveString, lpNetResource->lpRemoteName );
+
+ *pItem = pItemImpl;
+ }
+ return osl_File_E_None;
+ case ERROR_NO_MORE_ITEMS:
+ return osl_File_E_NOENT;
+ default:
+ return oslTranslateFileError( dwError );
+ }
+}
+
+//#####################################################
+static oslFileError SAL_CALL osl_getNextDrive(
+ oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint )
+{
+ Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
+ DirectoryItem_Impl *pItemImpl = NULL;
+ BOOL fSuccess;
+
+ uHint = uHint; /* avoid warnings */
+
+ if ( !pItem )
+ return osl_File_E_INVAL;
+ *pItem = NULL;
+
+ if ( !pDirImpl )
+ return osl_File_E_INVAL;
+
+ pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
+ if ( !pItemImpl )
+ return osl_File_E_NOMEM;
+
+ ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
+ pItemImpl->uType = DIRECTORYITEM_DRIVE;
+ osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
+ fSuccess = EnumLogicalDrives( pDirImpl->hEnumDrives, pItemImpl->cDriveString );
+
+ if ( fSuccess )
+ {
+ *pItem = pItemImpl;
+ return osl_File_E_None;
+ }
+ else
+ {
+ rtl_freeMemory( pItemImpl );
+ return oslTranslateFileError( GetLastError() );
+ }
+}
+
+//#####################################################
+static oslFileError SAL_CALL osl_getNextFileItem(
+ oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint)
+{
+ Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
+ DirectoryItem_Impl *pItemImpl = NULL;
+ BOOL fFound;
+
+ uHint = uHint; /* avoid warnings */
+
+ if ( !pItem )
+ return osl_File_E_INVAL;
+ *pItem = NULL;
+
+ if ( !pDirImpl )
+ return osl_File_E_INVAL;
+
+ pItemImpl = reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
+ if ( !pItemImpl )
+ return osl_File_E_NOMEM;
+
+ memset( pItemImpl, 0, sizeof(DirectoryItem_Impl) );
+ fFound = EnumDirectory( pDirImpl->hDirectory, &pItemImpl->FindData );
+
+ if ( fFound )
+ {
+ pItemImpl->uType = DIRECTORYITEM_FILE;
+ pItemImpl->nRefCount = 1;
+ _tcscpy( pItemImpl->szFullPath, pDirImpl->szDirectoryPath );
+ _tcscat( pItemImpl->szFullPath, pItemImpl->FindData.cFileName );
+ pItemImpl->bFullPathNormalized = FALSE;
+ *pItem = (oslDirectoryItem)pItemImpl;
+ return osl_File_E_None;
+ }
+ else
+ {
+ rtl_freeMemory( pItemImpl );
+ return oslTranslateFileError( GetLastError() );
+ }
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_getNextDirectoryItem(
+ oslDirectory Directory, oslDirectoryItem *pItem, sal_uInt32 uHint)
+{
+ Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
+
+ /* Assume failure */
+
+ if ( !pItem )
+ return osl_File_E_INVAL;
+ *pItem = NULL;
+
+ if ( !pDirImpl )
+ return osl_File_E_INVAL;
+
+ switch ( pDirImpl->uType )
+ {
+ case DIRECTORYTYPE_LOCALROOT:
+ return osl_getNextDrive( Directory, pItem, uHint );
+ case DIRECTORYTYPE_NETROOT:
+ return osl_getNextNetResource( Directory, pItem, uHint );
+ case DIRECTORYTYPE_FILESYSTEM:
+ return osl_getNextFileItem( Directory, pItem, uHint );
+ default:
+ return osl_File_E_INVAL;
+ }
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_closeDirectory(oslDirectory Directory)
+{
+ Directory_Impl *pDirImpl = (Directory_Impl *)Directory;
+ oslFileError eError = osl_File_E_INVAL;
+
+ if ( pDirImpl )
+ {
+ switch ( pDirImpl->uType )
+ {
+ case DIRECTORYTYPE_FILESYSTEM:
+ eError = CloseDirectory( pDirImpl->hDirectory ) ? osl_File_E_None : oslTranslateFileError( GetLastError() );
+ break;
+ case DIRECTORYTYPE_LOCALROOT:
+ eError = CloseLogicalDrivesEnum( pDirImpl->hEnumDrives ) ? osl_File_E_None : oslTranslateFileError( GetLastError() );
+ break;
+ case DIRECTORYTYPE_NETROOT:
+ {
+ DWORD err = WNetCloseEnum(pDirImpl->hDirectory);
+ eError = (err == NO_ERROR) ? osl_File_E_None : oslTranslateFileError(err);
+ }
+ break;
+ default:
+ OSL_ENSURE( 0, "Invalid directory type" );
+ break;
+ }
+
+ rtl_freeMemory(pDirImpl);
+ }
+ return eError;
+}
+
+//#####################################################
+/* Different types of paths */
+typedef enum _PATHTYPE
+{
+ PATHTYPE_SYNTAXERROR = 0,
+ PATHTYPE_NETROOT,
+ PATHTYPE_NETSERVER,
+ PATHTYPE_VOLUME,
+ PATHTYPE_FILE
+} PATHTYPE;
+
+oslFileError SAL_CALL osl_getDirectoryItem(rtl_uString *strFilePath, oslDirectoryItem *pItem)
+{
+ oslFileError error = osl_File_E_None;
+ rtl_uString* strSysFilePath = NULL;
+ PATHTYPE type = PATHTYPE_FILE;
+ DWORD dwPathType;
+
+ /* Assume failure */
+
+ if ( !pItem )
+ return osl_File_E_INVAL;
+
+ *pItem = NULL;
+
+
+ error = _osl_getSystemPathFromFileURL( strFilePath, &strSysFilePath, sal_False );
+
+ if ( osl_File_E_None != error )
+ return error;
+
+ dwPathType = IsValidFilePath( strSysFilePath, NULL, VALIDATEPATH_NORMAL, NULL );
+
+ if ( dwPathType & PATHTYPE_IS_VOLUME )
+ type = PATHTYPE_VOLUME;
+ else if ( dwPathType & PATHTYPE_IS_SERVER )
+ type = PATHTYPE_NETSERVER;
+ else
+ type = PATHTYPE_FILE;
+
+ switch ( type )
+ {
+ case PATHTYPE_NETSERVER:
+ {
+ DirectoryItem_Impl* pItemImpl =
+ reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
+
+ if ( !pItemImpl )
+ error = osl_File_E_NOMEM;
+
+ if ( osl_File_E_None == error )
+ {
+ ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
+ pItemImpl->uType = DIRECTORYITEM_SERVER;
+
+ osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
+
+ _tcscpy( pItemImpl->szFullPath, reinterpret_cast<LPCTSTR>(strSysFilePath->buffer) );
+
+ // Assign a title anyway
+ {
+ int iSrc = 2;
+ int iDst = 0;
+
+ while( iSrc < strSysFilePath->length && strSysFilePath->buffer[iSrc] && strSysFilePath->buffer[iSrc] != '\\' )
+ {
+ pItemImpl->FindData.cFileName[iDst++] = strSysFilePath->buffer[iSrc++];
+ }
+ }
+
+ *pItem = pItemImpl;
+ }
+ }
+ break;
+ case PATHTYPE_VOLUME:
+ {
+ DirectoryItem_Impl* pItemImpl =
+ reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
+
+ if ( !pItemImpl )
+ error = osl_File_E_NOMEM;
+
+ if ( osl_File_E_None == error )
+ {
+ ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
+ pItemImpl->uType = DIRECTORYITEM_DRIVE;
+
+ osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
+
+ _tcscpy( pItemImpl->cDriveString, reinterpret_cast<LPCTSTR>(strSysFilePath->buffer) );
+ pItemImpl->cDriveString[0] = _toupper( pItemImpl->cDriveString[0] );
+
+ if ( pItemImpl->cDriveString[_tcslen(pItemImpl->cDriveString) - 1] != '\\' )
+ _tcscat( pItemImpl->cDriveString, TEXT( "\\" ) );
+
+ *pItem = pItemImpl;
+ }
+ }
+ break;
+ case PATHTYPE_SYNTAXERROR:
+ case PATHTYPE_NETROOT:
+ case PATHTYPE_FILE:
+ {
+ HANDLE hFind;
+ WIN32_FIND_DATA aFindData;
+
+ if ( strSysFilePath->length > 0 && strSysFilePath->buffer[strSysFilePath->length - 1] == '\\' )
+ rtl_uString_newFromStr_WithLength( &strSysFilePath, strSysFilePath->buffer, strSysFilePath->length - 1 );
+
+ hFind = FindFirstFile( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysFilePath)), &aFindData );
+
+ if ( hFind != INVALID_HANDLE_VALUE )
+ {
+ DirectoryItem_Impl *pItemImpl =
+ reinterpret_cast<DirectoryItem_Impl*>(rtl_allocateMemory(sizeof(DirectoryItem_Impl)));
+
+ ZeroMemory( pItemImpl, sizeof(DirectoryItem_Impl) );
+ osl_acquireDirectoryItem( (oslDirectoryItem)pItemImpl );
+
+ CopyMemory( &pItemImpl->FindData, &aFindData, sizeof(WIN32_FIND_DATA) );
+ _tcscpy( pItemImpl->szFullPath, reinterpret_cast<LPCTSTR>(rtl_uString_getStr(strSysFilePath)) );
+
+ // MT: This costs 600ms startup time on fast v60x!
+ // GetCaseCorrectPathName( pItemImpl->szFullPath, pItemImpl->szFullPath, sizeof(pItemImpl->szFullPath) );
+
+ pItemImpl->uType = DIRECTORYITEM_FILE;
+ *pItem = pItemImpl;
+ FindClose( hFind );
+ }
+ else
+ error = oslTranslateFileError( GetLastError() );
+ }
+ break;
+ }
+
+ if ( strSysFilePath )
+ rtl_uString_release( strSysFilePath );
+
+ return error;
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_acquireDirectoryItem( oslDirectoryItem Item )
+{
+ DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
+
+ if ( !pItemImpl )
+ return osl_File_E_INVAL;
+
+ pItemImpl->nRefCount++;
+ return osl_File_E_None;
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_releaseDirectoryItem( oslDirectoryItem Item )
+{
+ DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
+
+ if ( !pItemImpl )
+ return osl_File_E_INVAL;
+
+ if ( ! --pItemImpl->nRefCount )
+ rtl_freeMemory( pItemImpl );
+ return osl_File_E_None;
+}
+
+//#####################################################
+// volume / file info handling functions
+//#####################################################
+
+//#####################################################
+static inline bool is_floppy_A_present()
+{ return (GetLogicalDrives() & 1); }
+
+//#####################################################
+static inline bool is_floppy_B_present()
+{ return (GetLogicalDrives() & 2); }
+
+//#####################################################
+bool is_floppy_volume_mount_point(const rtl::OUString& path)
+{
+ // determines if a volume mount point shows to a floppy
+ // disk by comparing the unique volume names
+ static const LPCWSTR FLOPPY_A = L"A:\\";
+ static const LPCWSTR FLOPPY_B = L"B:\\";
+
+ rtl::OUString p(path);
+ osl::systemPathEnsureSeparator(p);
+
+ TCHAR vn[51];
+ if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, ELEMENTS_OF_ARRAY(vn)))
+ {
+ TCHAR vnfloppy[51];
+ if (is_floppy_A_present() &&
+ GetVolumeNameForVolumeMountPoint(FLOPPY_A, vnfloppy, ELEMENTS_OF_ARRAY(vnfloppy)) &&
+ (0 == wcscmp(vn, vnfloppy)))
+ return true;
+
+ if (is_floppy_B_present() &&
+ GetVolumeNameForVolumeMountPoint(FLOPPY_B, vnfloppy, ELEMENTS_OF_ARRAY(vnfloppy)) &&
+ (0 == wcscmp(vn, vnfloppy)))
+ return true;
+ }
+ return false;
+}
+
+//################################################
+static bool is_floppy_drive(const rtl::OUString& path)
+{
+ static const LPCWSTR FLOPPY_DRV_LETTERS = TEXT("AaBb");
+
+ // we must take into account that even a floppy
+ // drive may be mounted to a directory so checking
+ // for the drive letter alone is not sufficient
+ // we must compare the unique volume name with
+ // that of the available floppy disks
+
+ const sal_Unicode* pszPath = path.getStr();
+ return ((wcschr(FLOPPY_DRV_LETTERS, pszPath[0]) && (L':' == pszPath[1])) || is_floppy_volume_mount_point(path));
+}
+
+//#####################################################
+static bool is_volume_mount_point(const rtl::OUString& path)
+{
+ rtl::OUString p(path);
+ osl::systemPathRemoveSeparator(p);
+
+ bool is_volume_root = false;
+
+ if (!is_floppy_drive(p))
+ {
+ DWORD fattr = GetFileAttributes(reinterpret_cast<LPCTSTR>(p.getStr()));
+
+ if ((INVALID_FILE_ATTRIBUTES != fattr) &&
+ (FILE_ATTRIBUTE_REPARSE_POINT & fattr))
+ {
+ WIN32_FIND_DATA find_data;
+ HANDLE h_find = FindFirstFile(reinterpret_cast<LPCTSTR>(p.getStr()), &find_data);
+
+ if (IsValidHandle(h_find) &&
+ (FILE_ATTRIBUTE_REPARSE_POINT & find_data.dwFileAttributes) &&
+ (IO_REPARSE_TAG_MOUNT_POINT == find_data.dwReserved0))
+ {
+ is_volume_root = true;
+ }
+ if (IsValidHandle(h_find))
+ FindClose(h_find);
+ }
+ }
+ return is_volume_root;
+}
+
+//#############################################
+static UINT get_volume_mount_point_drive_type(const rtl::OUString& path)
+{
+ if (0 == path.getLength())
+ return GetDriveType(NULL);
+
+ rtl::OUString p(path);
+ osl::systemPathEnsureSeparator(p);
+
+ TCHAR vn[51];
+ if (GetVolumeNameForVolumeMountPoint(reinterpret_cast<LPCTSTR>(p.getStr()), vn, ELEMENTS_OF_ARRAY(vn)))
+ return GetDriveType(vn);
+
+ return DRIVE_NO_ROOT_DIR;
+}
+
+//#############################################
+static inline bool is_drivetype_request(sal_uInt32 field_mask)
+{
+ return (field_mask & osl_VolumeInfo_Mask_Attributes);
+}
+
+//#############################################
+static oslFileError osl_get_drive_type(
+ const rtl::OUString& path, oslVolumeInfo* pInfo)
+{
+ // GetDriveType fails on empty volume mount points
+ // see Knowledge Base Q244089
+ UINT drive_type;
+ if (is_volume_mount_point(path))
+ drive_type = get_volume_mount_point_drive_type(path);
+ else
+ drive_type = GetDriveType(reinterpret_cast<LPCTSTR>(path.getStr()));
+
+ if (DRIVE_NO_ROOT_DIR == drive_type)
+ return oslTranslateFileError(ERROR_INVALID_DRIVE);
+
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes;
+
+ switch (drive_type)
+ {
+ case DRIVE_CDROM:
+ pInfo->uAttributes |= osl_Volume_Attribute_CompactDisc | osl_Volume_Attribute_Removeable;
+ break;
+ case DRIVE_REMOVABLE:
+ pInfo->uAttributes |= osl_Volume_Attribute_Removeable;
+ if (is_floppy_drive(path))
+ pInfo->uAttributes |= osl_Volume_Attribute_FloppyDisk;
+ break;
+ case DRIVE_FIXED:
+ pInfo->uAttributes |= osl_Volume_Attribute_FixedDisk;
+ break;
+ case DRIVE_RAMDISK:
+ pInfo->uAttributes |= osl_Volume_Attribute_RAMDisk;
+ break;
+ case DRIVE_REMOTE:
+ pInfo->uAttributes |= osl_Volume_Attribute_Remote;
+ break;
+ case DRIVE_UNKNOWN:
+ pInfo->uAttributes = 0;
+ break;
+ default:
+ pInfo->uValidFields &= ~osl_VolumeInfo_Mask_Attributes;
+ pInfo->uAttributes = 0;
+ break;
+ }
+ return osl_File_E_None;
+}
+
+//#############################################
+static inline bool is_volume_space_info_request(sal_uInt32 field_mask)
+{
+ return (field_mask &
+ (osl_VolumeInfo_Mask_TotalSpace |
+ osl_VolumeInfo_Mask_UsedSpace |
+ osl_VolumeInfo_Mask_FreeSpace));
+}
+
+//#############################################
+static void get_volume_space_information(
+ const rtl::OUString& path, oslVolumeInfo *pInfo)
+{
+ BOOL ret = GetDiskFreeSpaceEx(
+ reinterpret_cast<LPCTSTR>(path.getStr()),
+ (PULARGE_INTEGER)&(pInfo->uFreeSpace),
+ (PULARGE_INTEGER)&(pInfo->uTotalSpace),
+ NULL);
+
+ if (ret)
+ {
+ pInfo->uUsedSpace = pInfo->uTotalSpace - pInfo->uFreeSpace;
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_TotalSpace |
+ osl_VolumeInfo_Mask_UsedSpace |
+ osl_VolumeInfo_Mask_FreeSpace;
+ }
+}
+
+//#############################################
+static inline bool is_filesystem_attributes_request(sal_uInt32 field_mask)
+{
+ return (field_mask &
+ (osl_VolumeInfo_Mask_MaxNameLength |
+ osl_VolumeInfo_Mask_MaxPathLength |
+ osl_VolumeInfo_Mask_FileSystemName |
+ osl_VolumeInfo_Mask_FileSystemCaseHandling));
+}
+
+//#############################################
+static oslFileError get_filesystem_attributes(
+ const rtl::OUString& path, sal_uInt32 field_mask, oslVolumeInfo* pInfo)
+{
+ pInfo->uAttributes = 0;
+
+ // osl_get_drive_type must be called first because
+ // this function resets osl_VolumeInfo_Mask_Attributes
+ // on failure
+ if (is_drivetype_request(field_mask))
+ {
+ oslFileError osl_error = osl_get_drive_type(path, pInfo);
+ if (osl_File_E_None != osl_error)
+ return osl_error;
+ }
+ if (is_filesystem_attributes_request(field_mask))
+ {
+ WCHAR vn[MAX_PATH];
+ WCHAR fsn[MAX_PATH];
+ DWORD serial;
+ DWORD mcl;
+ DWORD flags;
+
+ LPCTSTR pszPath = reinterpret_cast<LPCTSTR>(path.getStr());
+ if (GetVolumeInformation(pszPath, vn, MAX_PATH, &serial, &mcl, &flags, fsn, MAX_PATH))
+ {
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxNameLength;
+ pInfo->uMaxNameLength = mcl;
+
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_MaxPathLength;
+ pInfo->uMaxPathLength = MAX_PATH;
+
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_FileSystemName;
+ rtl_uString_newFromStr(&pInfo->ustrFileSystemName, reinterpret_cast<const sal_Unicode*>(fsn));
+
+ // volumes (even NTFS) will always be considered case
+ // insensitive because the Win32 API is not able to
+ // deal with case sensitive volumes see M$ Knowledge Base
+ // article 100625 that's why we never set the attribute
+ // osl_Volume_Attribute_Case_Sensitive
+
+ if (flags & FS_CASE_IS_PRESERVED)
+ pInfo->uAttributes |= osl_Volume_Attribute_Case_Is_Preserved;
+
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_Attributes;
+ }
+ }
+ return osl_File_E_None;
+}
+
+//#####################################################
+static bool path_get_parent(rtl::OUString& path)
+{
+ OSL_PRECOND(path.lastIndexOf(SLASH) == -1, "Path must not have slashes");
+
+ if (!has_path_parent(path))
+ {
+ sal_Int32 i = path.lastIndexOf(BACKSLASH);
+ if (-1 < i)
+ {
+ path = rtl::OUString(path.getStr(), i);
+ return true;
+ }
+ }
+ return false;
+}
+
+//#####################################################
+static void path_travel_to_volume_root(const rtl::OUString& system_path, rtl::OUString& volume_root)
+{
+ rtl::OUString sys_path(system_path);
+
+ while(!is_volume_mount_point(sys_path) && path_get_parent(sys_path))
+ /**/;
+
+ volume_root = sys_path;
+ osl::systemPathEnsureSeparator(volume_root);
+}
+
+//#############################################
+oslFileError SAL_CALL osl_getVolumeInformation(
+ rtl_uString *ustrURL, oslVolumeInfo *pInfo, sal_uInt32 uFieldMask )
+{
+ if (!pInfo)
+ return osl_File_E_INVAL;
+
+ rtl::OUString system_path;
+ oslFileError error = _osl_getSystemPathFromFileURL(ustrURL, &system_path.pData, sal_False);
+
+ if (osl_File_E_None != error)
+ return error;
+
+ rtl::OUString volume_root;
+ path_travel_to_volume_root(system_path, volume_root);
+
+ pInfo->uValidFields = 0;
+
+ if ((error = get_filesystem_attributes(volume_root, uFieldMask, pInfo)) != osl_File_E_None)
+ return error;
+
+ if (is_volume_space_info_request(uFieldMask))
+ get_volume_space_information(volume_root, pInfo);
+
+ if (uFieldMask & osl_VolumeInfo_Mask_DeviceHandle)
+ {
+ pInfo->uValidFields |= osl_VolumeInfo_Mask_DeviceHandle;
+ osl_getFileURLFromSystemPath(volume_root.pData, (rtl_uString**)&pInfo->pDeviceHandle);
+ }
+
+ return osl_File_E_None;
+}
+
+//#####################################################
+static oslFileError SAL_CALL osl_getDriveInfo(
+ oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask)
+{
+ DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
+ TCHAR cDrive[3] = TEXT("A:");
+ TCHAR cRoot[4] = TEXT("A:\\");
+
+ if ( !pItemImpl )
+ return osl_File_E_INVAL;
+
+ pStatus->uValidFields = 0;
+
+ cDrive[0] = pItemImpl->cDriveString[0];
+ cRoot[0] = pItemImpl->cDriveString[0];
+
+ if ( uFieldMask & osl_FileStatus_Mask_FileName )
+ {
+ if ( pItemImpl->cDriveString[0] == '\\' && pItemImpl->cDriveString[1] == '\\' )
+ {
+ LPCWSTR lpFirstBkSlash = wcschr( &pItemImpl->cDriveString[2], '\\' );
+
+ if ( lpFirstBkSlash && lpFirstBkSlash[1] )
+ {
+ LPCWSTR lpLastBkSlash = wcschr( &lpFirstBkSlash[1], '\\' );
+
+ if ( lpLastBkSlash )
+ rtl_uString_newFromStr_WithLength( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(&lpFirstBkSlash[1]), lpLastBkSlash - lpFirstBkSlash - 1 );
+ else
+ rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(&lpFirstBkSlash[1]) );
+ pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
+ }
+ }
+ else switch ( GetDriveType( cRoot ) )
+ {
+ case DRIVE_REMOTE:
+ {
+ TCHAR szBuffer[1024];
+ DWORD const dwBufsizeConst = ELEMENTS_OF_ARRAY(szBuffer);
+ DWORD dwBufsize = dwBufsizeConst;
+
+ DWORD dwResult = WNetGetConnection( cDrive, szBuffer, &dwBufsize );
+ if ( NO_ERROR == dwResult )
+ {
+ TCHAR szFileName[dwBufsizeConst + 16];
+
+ swprintf( szFileName, L"%s [%s]", cDrive, szBuffer );
+ rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(szFileName) );
+ }
+ else
+ rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cDrive) );
+ }
+ pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
+ break;
+ case DRIVE_FIXED:
+ {
+ TCHAR szVolumeNameBuffer[1024];
+ DWORD const dwBufsizeConst = ELEMENTS_OF_ARRAY(szVolumeNameBuffer);
+
+ if ( GetVolumeInformation( cRoot, szVolumeNameBuffer, dwBufsizeConst, NULL, NULL, NULL, NULL, 0 ) )
+ {
+ TCHAR szFileName[dwBufsizeConst + 16];
+
+ swprintf( szFileName, L"%s [%s]", cDrive, szVolumeNameBuffer );
+ rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(szFileName) );
+ }
+ else
+ rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cDrive) );
+ }
+ pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
+ break;
+ case DRIVE_CDROM:
+ case DRIVE_REMOVABLE:
+ pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
+ rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(cRoot) );
+ break;
+ case DRIVE_UNKNOWN:
+ default:
+ break;
+ }
+ }
+
+ pStatus->eType = osl_File_Type_Volume;
+ pStatus->uValidFields |= osl_FileStatus_Mask_Type;
+
+ if ( uFieldMask & osl_FileStatus_Mask_FileURL )
+ {
+ rtl_uString *ustrSystemPath = NULL;
+
+ rtl_uString_newFromStr( &ustrSystemPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->cDriveString) );
+ osl_getFileURLFromSystemPath( ustrSystemPath, &pStatus->ustrFileURL );
+ rtl_uString_release( ustrSystemPath );
+ pStatus->uValidFields |= osl_FileStatus_Mask_FileURL;
+ }
+ return osl_File_E_None;
+}
+
+//#####################################################
+static oslFileError SAL_CALL osl_getServerInfo(
+ oslDirectoryItem Item, oslFileStatus *pStatus, sal_uInt32 uFieldMask )
+{
+ DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
+ if ( !pItemImpl )
+ return osl_File_E_INVAL;
+
+ pStatus->uValidFields = 0;
+
+ // pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
+
+ // if ( _tcscmp( pItemImpl->FindData.cFileName, TEXT(".") ) == 0 )
+ // rtl_uString_newFromAscii( &pStatus->ustrFileName, "/" );
+ // else
+ // rtl_uString_newFromStr( &pStatus->ustrFileName, pItemImpl->FindData.cFileName );
+
+ pStatus->eType = osl_File_Type_Directory;
+ pStatus->uValidFields |= osl_FileStatus_Mask_Type;
+
+ if ( uFieldMask & osl_FileStatus_Mask_FileURL )
+ {
+ rtl_uString *ustrSystemPath = NULL;
+
+ rtl_uString_newFromStr( &ustrSystemPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) );
+ osl_getFileURLFromSystemPath( ustrSystemPath, &pStatus->ustrFileURL );
+ rtl_uString_release( ustrSystemPath );
+ pStatus->uValidFields |= osl_FileStatus_Mask_FileURL;
+ }
+ return osl_File_E_None;
+}
+
+//#############################################
+oslFileError SAL_CALL osl_getFileStatus(
+ oslDirectoryItem Item,
+ oslFileStatus *pStatus,
+ sal_uInt32 uFieldMask )
+{
+ DirectoryItem_Impl *pItemImpl = (DirectoryItem_Impl *)Item;
+
+ if ( !pItemImpl )
+ return osl_File_E_INVAL;
+
+ switch ( pItemImpl->uType )
+ {
+ case DIRECTORYITEM_DRIVE:
+ return osl_getDriveInfo( Item, pStatus, uFieldMask );
+ case DIRECTORYITEM_SERVER:
+ return osl_getServerInfo( Item, pStatus, uFieldMask );
+ default:
+ break;
+ }
+
+ if ( uFieldMask & osl_FileStatus_Mask_Validate )
+ {
+ HANDLE hFind = FindFirstFile( pItemImpl->szFullPath, &pItemImpl->FindData );
+
+ if ( hFind != INVALID_HANDLE_VALUE )
+ FindClose( hFind );
+ else
+ return oslTranslateFileError( GetLastError() );
+
+ uFieldMask &= ~ osl_FileStatus_Mask_Validate;
+ }
+
+ /* If no fields to retrieve left ignore pStatus */
+ if ( !uFieldMask )
+ return osl_File_E_None;
+
+ /* Otherwise, this must be a valid pointer */
+ if ( !pStatus )
+ return osl_File_E_INVAL;
+
+ if ( pStatus->uStructSize != sizeof(oslFileStatus) )
+ return osl_File_E_INVAL;
+
+ pStatus->uValidFields = 0;
+
+ /* File time stamps */
+
+ if ( (uFieldMask & osl_FileStatus_Mask_ModifyTime) &&
+ FileTimeToTimeValue( &pItemImpl->FindData.ftLastWriteTime, &pStatus->aModifyTime ) )
+ pStatus->uValidFields |= osl_FileStatus_Mask_ModifyTime;
+
+ if ( (uFieldMask & osl_FileStatus_Mask_AccessTime) &&
+ FileTimeToTimeValue( &pItemImpl->FindData.ftLastAccessTime, &pStatus->aAccessTime ) )
+ pStatus->uValidFields |= osl_FileStatus_Mask_AccessTime;
+
+ if ( (uFieldMask & osl_FileStatus_Mask_CreationTime) &&
+ FileTimeToTimeValue( &pItemImpl->FindData.ftCreationTime, &pStatus->aCreationTime ) )
+ pStatus->uValidFields |= osl_FileStatus_Mask_CreationTime;
+
+ /* Most of the fields are already set, regardless of requiered fields */
+
+ rtl_uString_newFromStr( &pStatus->ustrFileName, reinterpret_cast<const sal_Unicode*>(pItemImpl->FindData.cFileName) );
+ pStatus->uValidFields |= osl_FileStatus_Mask_FileName;
+
+ if ((FILE_ATTRIBUTE_REPARSE_POINT & pItemImpl->FindData.dwFileAttributes) &&
+ (IO_REPARSE_TAG_MOUNT_POINT == pItemImpl->FindData.dwReserved0))
+ pStatus->eType = osl_File_Type_Volume;
+ else if (pItemImpl->FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ pStatus->eType = osl_File_Type_Directory;
+ else
+ pStatus->eType = osl_File_Type_Regular;
+
+ pStatus->uValidFields |= osl_FileStatus_Mask_Type;
+
+ pStatus->uAttributes = pItemImpl->FindData.dwFileAttributes;
+ pStatus->uValidFields |= osl_FileStatus_Mask_Attributes;
+
+ pStatus->uFileSize = (sal_uInt64)pItemImpl->FindData.nFileSizeLow + ((sal_uInt64)pItemImpl->FindData.nFileSizeHigh << 32);
+ pStatus->uValidFields |= osl_FileStatus_Mask_FileSize;
+
+ if ( uFieldMask & osl_FileStatus_Mask_LinkTargetURL )
+ {
+ rtl_uString *ustrFullPath = NULL;
+
+ rtl_uString_newFromStr( &ustrFullPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) );
+ osl_getFileURLFromSystemPath( ustrFullPath, &pStatus->ustrLinkTargetURL );
+ rtl_uString_release( ustrFullPath );
+
+ pStatus->uValidFields |= osl_FileStatus_Mask_LinkTargetURL;
+ }
+
+ if ( uFieldMask & osl_FileStatus_Mask_FileURL )
+ {
+ rtl_uString *ustrFullPath = NULL;
+
+
+ if ( !pItemImpl->bFullPathNormalized )
+ {
+ GetCaseCorrectPathName( pItemImpl->szFullPath, pItemImpl->szFullPath, sizeof(pItemImpl->szFullPath) );
+ pItemImpl->bFullPathNormalized = TRUE;
+ }
+ rtl_uString_newFromStr( &ustrFullPath, reinterpret_cast<const sal_Unicode*>(pItemImpl->szFullPath) );
+ osl_getFileURLFromSystemPath( ustrFullPath, &pStatus->ustrFileURL );
+ rtl_uString_release( ustrFullPath );
+ pStatus->uValidFields |= osl_FileStatus_Mask_FileURL;
+ }
+
+ return osl_File_E_None;
+}
+
+//#####################################################
+// file attributes handling functions
+//#####################################################
+
+//#############################################
+oslFileError SAL_CALL osl_setFileAttributes(
+ rtl_uString *ustrFileURL,
+ sal_uInt64 uAttributes )
+{
+ oslFileError error;
+ rtl_uString *ustrSysPath = NULL;
+ DWORD dwFileAttributes;
+ BOOL fSuccess;
+
+ // Converts the normalized path into a systempath
+ error = _osl_getSystemPathFromFileURL( ustrFileURL, &ustrSysPath, sal_False );
+
+ if ( osl_File_E_None != error )
+ return error;
+
+ dwFileAttributes = GetFileAttributes( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(ustrSysPath)) );
+
+ if ( (DWORD)-1 != dwFileAttributes )
+ {
+ dwFileAttributes &= ~(FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN);
+
+ if ( uAttributes & osl_File_Attribute_ReadOnly )
+ dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
+
+ if ( uAttributes & osl_File_Attribute_Hidden )
+ dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;
+
+ fSuccess = SetFileAttributes( reinterpret_cast<LPCTSTR>(rtl_uString_getStr(ustrSysPath)), dwFileAttributes );
+ }
+ else
+ fSuccess = FALSE;
+
+ if ( !fSuccess )
+ error = oslTranslateFileError( GetLastError() );
+
+ rtl_uString_release( ustrSysPath );
+
+ return error;
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_setFileTime(
+ rtl_uString *filePath,
+ const TimeValue *aCreationTime,
+ const TimeValue *aLastAccessTime,
+ const TimeValue *aLastWriteTime)
+{
+ oslFileError error;
+ rtl_uString *sysPath=NULL;
+ FILETIME *lpCreationTime=NULL;
+ FILETIME *lpLastAccessTime=NULL;
+ FILETIME *lpLastWriteTime=NULL;
+ FILETIME ftCreationTime;
+ FILETIME ftLastAccessTime;
+ FILETIME ftLastWriteTime;
+ HANDLE hFile;
+ BOOL fSuccess;
+
+
+ error=_osl_getSystemPathFromFileURL(filePath, &sysPath, sal_False);
+
+ if (error==osl_File_E_INVAL)
+ return error;
+
+ hFile=CreateFileW(reinterpret_cast<LPCWSTR>(rtl_uString_getStr(sysPath)), GENERIC_WRITE, 0, NULL , OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ rtl_uString_release(sysPath);
+
+ if (hFile==INVALID_HANDLE_VALUE)
+ return osl_File_E_NOENT;
+
+ if (TimeValueToFileTime(aCreationTime, &ftCreationTime))
+ lpCreationTime=&ftCreationTime;
+
+ if (TimeValueToFileTime(aLastAccessTime, &ftLastAccessTime))
+ lpLastAccessTime=&ftLastAccessTime;
+
+ if (TimeValueToFileTime(aLastWriteTime, &ftLastWriteTime))
+ lpLastWriteTime=&ftLastWriteTime;
+
+ fSuccess=SetFileTime(hFile, lpCreationTime, lpLastAccessTime, lpLastWriteTime);
+
+ CloseHandle(hFile);
+
+ if (!fSuccess)
+ return osl_File_E_INVAL;
+ else
+ return osl_File_E_None;
+}
diff --git a/sal/osl/w32/file_error.c b/sal/osl/w32/file_error.c
new file mode 100644
index 000000000000..3942420eb8da
--- /dev/null
+++ b/sal/osl/w32/file_error.c
@@ -0,0 +1,154 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: file_error.c,v $
+ * $Revision: 1.0 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define UNICODE
+#define _UNICODE
+#define _WIN32_WINNT_0x0500
+#include "systools/win32/uwinapi.h"
+
+#include "file_error.h"
+
+#include "osl/diagnose.h"
+#include "osl/thread.h"
+
+/* OS error to oslFileError values mapping table */
+struct osl_file_error_entry
+{
+ unsigned long oscode; /* OS return value */
+ int errnocode; /* oslFileError code */
+};
+
+static const struct osl_file_error_entry errtable[] = {
+ { ERROR_SUCCESS, osl_File_E_None }, /* 0 */
+ { ERROR_INVALID_FUNCTION, osl_File_E_INVAL }, /* 1 */
+ { ERROR_FILE_NOT_FOUND, osl_File_E_NOENT }, /* 2 */
+ { ERROR_PATH_NOT_FOUND, osl_File_E_NOENT }, /* 3 */
+ { ERROR_TOO_MANY_OPEN_FILES, osl_File_E_MFILE }, /* 4 */
+ { ERROR_ACCESS_DENIED, osl_File_E_ACCES }, /* 5 */
+ { ERROR_INVALID_HANDLE, osl_File_E_BADF }, /* 6 */
+ { ERROR_ARENA_TRASHED, osl_File_E_NOMEM }, /* 7 */
+ { ERROR_NOT_ENOUGH_MEMORY, osl_File_E_NOMEM }, /* 8 */
+ { ERROR_INVALID_BLOCK, osl_File_E_NOMEM }, /* 9 */
+ { ERROR_BAD_ENVIRONMENT, osl_File_E_2BIG }, /* 10 */
+ { ERROR_BAD_FORMAT, osl_File_E_NOEXEC }, /* 11 */
+ { ERROR_INVALID_ACCESS, osl_File_E_INVAL }, /* 12 */
+ { ERROR_INVALID_DATA, osl_File_E_INVAL }, /* 13 */
+ { ERROR_INVALID_DRIVE, osl_File_E_NOENT }, /* 15 */
+ { ERROR_CURRENT_DIRECTORY, osl_File_E_ACCES }, /* 16 */
+ { ERROR_NOT_SAME_DEVICE, osl_File_E_XDEV }, /* 17 */
+ { ERROR_NO_MORE_FILES, osl_File_E_NOENT }, /* 18 */
+ { ERROR_NOT_READY, osl_File_E_NOTREADY }, /* 21 */
+ { ERROR_LOCK_VIOLATION, osl_File_E_ACCES }, /* 33 */
+ { ERROR_BAD_NETPATH, osl_File_E_NOENT }, /* 53 */
+ { ERROR_NETWORK_ACCESS_DENIED, osl_File_E_ACCES }, /* 65 */
+ { ERROR_BAD_NET_NAME, osl_File_E_NOENT }, /* 67 */
+ { ERROR_FILE_EXISTS, osl_File_E_EXIST }, /* 80 */
+ { ERROR_CANNOT_MAKE, osl_File_E_ACCES }, /* 82 */
+ { ERROR_FAIL_I24, osl_File_E_ACCES }, /* 83 */
+ { ERROR_INVALID_PARAMETER, osl_File_E_INVAL }, /* 87 */
+ { ERROR_NO_PROC_SLOTS, osl_File_E_AGAIN }, /* 89 */
+ { ERROR_DRIVE_LOCKED, osl_File_E_ACCES }, /* 108 */
+ { ERROR_BROKEN_PIPE, osl_File_E_PIPE }, /* 109 */
+ { ERROR_DISK_FULL, osl_File_E_NOSPC }, /* 112 */
+ { ERROR_INVALID_TARGET_HANDLE, osl_File_E_BADF }, /* 114 */
+ { ERROR_INVALID_HANDLE, osl_File_E_INVAL }, /* 124 */
+ { ERROR_WAIT_NO_CHILDREN, osl_File_E_CHILD }, /* 128 */
+ { ERROR_CHILD_NOT_COMPLETE, osl_File_E_CHILD }, /* 129 */
+ { ERROR_DIRECT_ACCESS_HANDLE, osl_File_E_BADF }, /* 130 */
+ { ERROR_NEGATIVE_SEEK, osl_File_E_INVAL }, /* 131 */
+ { ERROR_SEEK_ON_DEVICE, osl_File_E_ACCES }, /* 132 */
+ { ERROR_DIR_NOT_EMPTY, osl_File_E_NOTEMPTY }, /* 145 */
+ { ERROR_NOT_LOCKED, osl_File_E_ACCES }, /* 158 */
+ { ERROR_BAD_PATHNAME, osl_File_E_NOENT }, /* 161 */
+ { ERROR_MAX_THRDS_REACHED, osl_File_E_AGAIN }, /* 164 */
+ { ERROR_LOCK_FAILED, osl_File_E_ACCES }, /* 167 */
+ { ERROR_ALREADY_EXISTS, osl_File_E_EXIST }, /* 183 */
+ { ERROR_FILENAME_EXCED_RANGE, osl_File_E_NOENT }, /* 206 */
+ { ERROR_NESTING_NOT_ALLOWED, osl_File_E_AGAIN }, /* 215 */
+ { ERROR_DIRECTORY, osl_File_E_NOENT }, /* 267 */
+ { ERROR_NOT_ENOUGH_QUOTA, osl_File_E_NOMEM }, /* 1816 */
+ { ERROR_UNEXP_NET_ERR, osl_File_E_NETWORK } /* 59 */
+};
+
+/* The following two constants must be the minimum and maximum
+ values in the (contiguous) range of osl_File_E_xec Failure errors.
+*/
+#define MIN_EXEC_ERROR ERROR_INVALID_STARTING_CODESEG
+#define MAX_EXEC_ERROR ERROR_INFLOOP_IN_RELOC_CHAIN
+
+/* These are the low and high value in the range of errors that are
+ access violations
+*/
+#define MIN_EACCES_RANGE ERROR_WRITE_PROTECT
+#define MAX_EACCES_RANGE ERROR_SHARING_BUFFER_EXCEEDED
+
+oslFileError oslTranslateFileError (/*DWORD*/ unsigned long dwError)
+{
+ static const int n = sizeof(errtable)/sizeof(errtable[0]);
+
+ int i;
+ for (i = 0; i < n; ++i )
+ {
+ if (dwError == errtable[i].oscode)
+ return (oslFileError)(errtable[i].errnocode);
+ }
+
+ /* The error code wasn't in the table. We check for a range of
+ osl_File_E_ACCES errors or exec failure errors (ENOEXEC).
+ Otherwise osl_File_E_INVAL is returned.
+ */
+ if ( (dwError >= MIN_EACCES_RANGE) && (dwError <= MAX_EACCES_RANGE) )
+ return osl_File_E_ACCES;
+ else if ( (dwError >= MIN_EXEC_ERROR) && (dwError <= MAX_EXEC_ERROR) )
+ return osl_File_E_NOEXEC;
+ else
+ return osl_File_E_INVAL;
+}
+
+//#####################################################
+#if OSL_DEBUG_LEVEL > 0
+void _osl_warnFile( const char *message, rtl_uString *ustrFile )
+{
+ char szBuffer[2048];
+
+ if (ustrFile)
+ {
+ rtl_String *strFile = NULL;
+
+ rtl_uString2String( &strFile, rtl_uString_getStr( ustrFile ), rtl_uString_getLength( ustrFile ),
+ osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS );
+ snprintf( szBuffer, sizeof(szBuffer), message, strFile->buffer );
+ rtl_string_release( strFile );
+
+ message = szBuffer;
+ }
+ OSL_ENSURE( 0, message );
+}
+#endif /* OSL_DEBUG_LEVEL */
diff --git a/sal/osl/w32/file_error.h b/sal/osl/w32/file_error.h
new file mode 100644
index 000000000000..caebbdb1c560
--- /dev/null
+++ b/sal/osl/w32/file_error.h
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: file_error.h,v $
+ * $Revision: 1.0 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_OSL_FILE_ERROR_H
+#define INCLUDED_OSL_FILE_ERROR_H
+
+#include "osl/file.h"
+#include "rtl/ustring.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+oslFileError oslTranslateFileError (/*DWORD*/ unsigned long dwError);
+
+#if OSL_DEBUG_LEVEL > 0
+void _osl_warnFile (const char * message, rtl_uString * ustrFile);
+#define OSL_ENSURE_FILE( cond, msg, file ) ( (cond) ? (void)0 : _osl_warnFile( msg, file ) )
+#else
+#define OSL_ENSURE_FILE( cond, msg, file ) ((void)0)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* INCLUDED_OSL_FILE_ERROR_H */
diff --git a/sal/osl/w32/file_url.cxx b/sal/osl/w32/file_url.cxx
new file mode 100644
index 000000000000..968c4bccc95e
--- /dev/null
+++ b/sal/osl/w32/file_url.cxx
@@ -0,0 +1,1013 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: file_url.cxx,v $
+ * $Revision: 1.0 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define UNICODE
+#define _UNICODE
+#define _WIN32_WINNT_0x0500
+#include "systools/win32/uwinapi.h"
+
+#include "file_url.h"
+#include "file_error.h"
+
+#include "rtl/alloc.h"
+#include "osl/diagnose.h"
+#include "osl/file.h"
+#include "osl/mutex.h"
+
+#include <stdio.h>
+#include <tchar.h>
+
+#if OSL_DEBUG_LEVEL > 0
+#define OSL_ENSURE_FILE( cond, msg, file ) ( (cond) ? (void)0 : _osl_warnFile( msg, file ) )
+#else
+#define OSL_ENSURE_FILE( cond, msg, file ) ((void)0)
+#endif
+
+#define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0])))
+
+//##################################################################
+// FileURL functions
+//##################################################################
+
+extern "C" oslMutex g_CurrentDirectoryMutex; /* Initialized in dllentry.c */
+oslMutex g_CurrentDirectoryMutex = 0;
+
+//#####################################################
+static BOOL IsValidFilePathComponent(
+ LPCTSTR lpComponent, LPCTSTR *lppComponentEnd, DWORD dwFlags)
+{
+ LPCTSTR lpComponentEnd = NULL;
+ LPCTSTR lpCurrent = lpComponent;
+ BOOL fValid = TRUE; /* Assume success */
+ TCHAR cLast = 0;
+
+ /* Path component length must not exceed MAX_PATH */
+
+ while ( !lpComponentEnd && lpCurrent && lpCurrent - lpComponent < MAX_PATH )
+ {
+ switch ( *lpCurrent )
+ {
+ /* Both backslash and slash determine the end of a path component */
+ case '\0':
+ case '/':
+ case '\\':
+ switch ( cLast )
+ {
+ /* Component must not end with '.' or blank and can't be empty */
+
+ case '.':
+ if ( dwFlags & VALIDATEPATH_ALLOW_ELLIPSE )
+ {
+ if ( 1 == lpCurrent - lpComponent )
+ {
+ /* Current directory is O.K. */
+ lpComponentEnd = lpCurrent;
+ break;
+ }
+ else if ( 2 == lpCurrent - lpComponent && '.' == *lpComponent )
+ {
+ /* Parent directory is O.K. */
+ lpComponentEnd = lpCurrent;
+ break;
+ }
+ }
+ case 0:
+ case ' ':
+ lpComponentEnd = lpCurrent - 1;
+ fValid = FALSE;
+ break;
+ default:
+ lpComponentEnd = lpCurrent;
+ break;
+ }
+ break;
+ /* '?' and '*' are valid wildcards but not valid file name characters */
+ case '?':
+ case '*':
+ if ( dwFlags & VALIDATEPATH_ALLOW_WILDCARDS )
+ break;
+ /* The following characters are reserved */
+ case '<':
+ case '>':
+ case '\"':
+ case '|':
+ case ':':
+ lpComponentEnd = lpCurrent;
+ fValid = FALSE;
+ break;
+ default:
+ /* Characters below ASCII 32 are not allowed */
+ if ( *lpCurrent < ' ' )
+ {
+ lpComponentEnd = lpCurrent;
+ fValid = FALSE;
+ }
+ break;
+ }
+ cLast = *lpCurrent++;
+ }
+
+ /* If we don't reached the end of the component the length of the component was to long
+ ( See condition of while loop ) */
+ if ( !lpComponentEnd )
+ {
+ fValid = FALSE;
+ lpComponentEnd = lpCurrent;
+ }
+
+ /* Test wether the component specifies a device name what is not allowed */
+
+ // MT: PERFORMANCE:
+ // This is very expensive. A lot of calls to _tcsicmp.
+ // in SRC6870m71 67.000 calls of this method while empty office start result into more than 1.500.00 calls of _tcsicmp!
+ // Possible optimizations
+ // - Array should be const static
+ // - Sorted array, use binary search
+ // - More intelligent check for com1-9, lpt1-9
+ // Maybe make szComponent upper case, don't search case intensitive
+ // Talked to HRO: Could be removed. Shouldn't be used in OOo, and if used for something like a filename, it will lead to an error anyway.
+ /*
+ if ( fValid )
+ {
+ LPCTSTR alpDeviceNames[] =
+ {
+ TEXT("CON"),
+ TEXT("PRN"),
+ TEXT("AUX"),
+ TEXT("CLOCK$"),
+ TEXT("NUL"),
+ TEXT("LPT1"),
+ TEXT("LPT2"),
+ TEXT("LPT3"),
+ TEXT("LPT4"),
+ TEXT("LPT5"),
+ TEXT("LPT6"),
+ TEXT("LPT7"),
+ TEXT("LPT8"),
+ TEXT("LPT9"),
+ TEXT("COM1"),
+ TEXT("COM2"),
+ TEXT("COM3"),
+ TEXT("COM4"),
+ TEXT("COM5"),
+ TEXT("COM6"),
+ TEXT("COM7"),
+ TEXT("COM8"),
+ TEXT("COM9")
+ };
+
+ TCHAR szComponent[MAX_PATH];
+ int nComponentLength;
+ LPCTSTR lpDot;
+ int i;
+
+ // A device name with an extension is also invalid
+ lpDot = _tcschr( lpComponent, '.' );
+
+ if ( !lpDot || lpDot > lpComponentEnd )
+ nComponentLength = lpComponentEnd - lpComponent;
+ else
+ nComponentLength = lpDot - lpComponent;
+
+ _tcsncpy( szComponent, lpComponent, nComponentLength );
+ szComponent[nComponentLength] = 0;
+
+ for ( i = 0; i < sizeof( alpDeviceNames ) / sizeof(LPCTSTR); i++ )
+ {
+ if ( 0 == _tcsicmp( szComponent, alpDeviceNames[i] ) )
+ {
+ lpComponentEnd = lpComponent;
+ fValid = FALSE;
+ break;
+ }
+ }
+ }
+ */
+
+ if ( fValid )
+ {
+ // Empty components are not allowed
+ if ( lpComponentEnd - lpComponent < 1 )
+ fValid = FALSE;
+
+ // If we reached the end of the string NULL is returned
+ else if ( !*lpComponentEnd )
+ lpComponentEnd = NULL;
+
+ }
+
+ if ( lppComponentEnd )
+ *lppComponentEnd = lpComponentEnd;
+
+ return fValid;
+}
+
+//#####################################################
+#define CHARSET_SEPARATOR TEXT("\\/")
+
+DWORD IsValidFilePath(rtl_uString *path, LPCTSTR *lppError, DWORD dwFlags, rtl_uString **corrected)
+{
+ LPCTSTR lpszPath = reinterpret_cast< LPCTSTR >(path->buffer);
+ LPCTSTR lpComponent;
+ BOOL fValid = TRUE;
+ DWORD dwPathType = PATHTYPE_ERROR;
+
+ if ( dwFlags & VALIDATEPATH_ALLOW_RELATIVE )
+ dwFlags |= VALIDATEPATH_ALLOW_ELLIPSE;
+
+ if ( !lpszPath )
+ {
+ fValid = FALSE;
+ lpComponent = lpszPath;
+ }
+
+ /* Test for UNC path notation */
+ if ( 2 == _tcsspn( lpszPath, CHARSET_SEPARATOR ) )
+ {
+ /* Place the pointer behind the leading to backslashes */
+
+ lpComponent = lpszPath + 2;
+
+ fValid = IsValidFilePathComponent( lpComponent, &lpComponent, VALIDATEPATH_ALLOW_ELLIPSE );
+
+ /* So far we have a valid servername. Now let's see if we also have a network resource */
+
+ dwPathType = PATHTYPE_ABSOLUTE_UNC;
+
+ if ( fValid )
+ {
+ if ( lpComponent && !*++lpComponent )
+ lpComponent = NULL;
+
+ if ( !lpComponent )
+ {
+ #if 0
+ /* We only have a Server specification what is invalid */
+
+ lpComponent = lpszPath;
+ fValid = FALSE;
+ #else
+ dwPathType |= PATHTYPE_IS_SERVER;
+ #endif
+ }
+ else
+ {
+ /* Now test the network resource */
+
+ fValid = IsValidFilePathComponent( lpComponent, &lpComponent, 0 );
+
+ /* If we now reached the end of the path, everything is O.K. */
+
+
+ if ( fValid && (!lpComponent || lpComponent && !*++lpComponent ) )
+ {
+ lpComponent = NULL;
+ dwPathType |= PATHTYPE_IS_VOLUME;
+ }
+ }
+ }
+ }
+
+ /* Local path verification. Must start with <drive>: */
+ else if ( _istalpha( lpszPath[0] ) && ':' == lpszPath[1] )
+ {
+ /* Place pointer behind correct drive specification */
+
+ lpComponent = lpszPath + 2;
+
+ if ( 1 == _tcsspn( lpComponent, CHARSET_SEPARATOR ) )
+ lpComponent++;
+ else if ( *lpComponent )
+ fValid = FALSE;
+
+ dwPathType = PATHTYPE_ABSOLUTE_LOCAL;
+
+ /* Now we are behind the backslash or it was a simple drive without backslash */
+
+ if ( fValid && !*lpComponent )
+ {
+ lpComponent = NULL;
+ dwPathType |= PATHTYPE_IS_VOLUME;
+ }
+ }
+
+ /* Can be a relative path */
+ else if ( dwFlags & VALIDATEPATH_ALLOW_RELATIVE )
+ {
+ lpComponent = lpszPath;
+
+ /* Relative path can start with a backslash */
+
+ if ( 1 == _tcsspn( lpComponent, CHARSET_SEPARATOR ) )
+ {
+ lpComponent++;
+ if ( !*lpComponent )
+ lpComponent = NULL;
+ }
+
+ dwPathType = PATHTYPE_RELATIVE;
+ }
+
+ /* Anything else is an error */
+ else
+ {
+ fValid = FALSE;
+ lpComponent = lpszPath;
+ }
+
+ /* Now validate each component of the path */
+ while ( fValid && lpComponent )
+ {
+ // Correct path by merging consecutive slashes:
+ if (*lpComponent == '\\' && corrected != NULL) {
+ sal_Int32 i = lpComponent - lpszPath;
+ rtl_uString_newReplaceStrAt(corrected, path, i, 1, NULL);
+ //TODO: handle out-of-memory
+ lpszPath = reinterpret_cast< LPCTSTR >((*corrected)->buffer);
+ lpComponent = lpszPath + i;
+ }
+
+ fValid = IsValidFilePathComponent( lpComponent, &lpComponent, dwFlags );
+
+ if ( fValid && lpComponent )
+ {
+ lpComponent++;
+
+ /* If the string behind the backslash is empty, we've done */
+
+ if ( !*lpComponent )
+ lpComponent = NULL;
+ }
+ }
+
+ if ( fValid && _tcslen( lpszPath ) >= MAX_PATH )
+ {
+ fValid = FALSE;
+ lpComponent = lpszPath + MAX_PATH;
+ }
+
+ if ( lppError )
+ *lppError = lpComponent;
+
+ return fValid ? dwPathType : PATHTYPE_ERROR;
+}
+
+//#############################################
+//#####################################################
+//Undocumented in SHELL32.DLL ordinal 35
+static BOOL PathRemoveFileSpec(LPTSTR lpPath)
+{
+ BOOL fSuccess = FALSE; // Assume failure
+ LPTSTR lpLastBkSlash = _tcsrchr( lpPath, '\\' );
+ LPTSTR lpLastSlash = _tcsrchr( lpPath, '/' );
+ LPTSTR lpLastDelimiter = lpLastSlash > lpLastBkSlash ? lpLastSlash : lpLastBkSlash;
+
+ if ( lpLastDelimiter )
+ {
+ if ( 0 == *(lpLastDelimiter + 1) )
+ {
+ if ( lpLastDelimiter > lpPath && *(lpLastDelimiter - 1) != ':' )
+ {
+ *lpLastDelimiter = 0;
+ fSuccess = TRUE;
+ }
+ }
+ else
+ {
+ *(++lpLastDelimiter) = 0;
+ fSuccess = TRUE;
+ }
+ }
+ return fSuccess;
+}
+
+//#####################################################
+// Undocumented in SHELL32.DLL ordinal 32
+static LPTSTR PathAddBackslash(LPTSTR lpPath)
+{
+ LPTSTR lpEndPath = NULL;
+
+ if ( lpPath )
+ {
+ int nLen = _tcslen(lpPath);
+
+ if ( !nLen || lpPath[nLen-1] != '\\' && lpPath[nLen-1] != '/' && nLen < MAX_PATH - 1 )
+ {
+ lpEndPath = lpPath + nLen;
+ *lpEndPath++ = '\\';
+ *lpEndPath = 0;
+ }
+ }
+ return lpEndPath;
+}
+
+//#####################################################
+// Same as GetLongPathName but also 95/NT4
+static DWORD GetCaseCorrectPathNameEx(
+ LPCTSTR lpszShortPath, // file name
+ LPTSTR lpszLongPath, // path buffer
+ DWORD cchBuffer, // size of path buffer
+ DWORD nSkipLevels
+)
+{
+ TCHAR szPath[MAX_PATH];
+ BOOL fSuccess;
+
+ cchBuffer = cchBuffer; /* avoid warnings */
+
+ _tcscpy( szPath, lpszShortPath );
+
+ fSuccess = PathRemoveFileSpec( szPath );
+
+ if ( fSuccess )
+ {
+ int nLen = _tcslen( szPath );
+ LPCTSTR lpszFileSpec = lpszShortPath + nLen;
+ BOOL bSkipThis;
+
+ if ( 0 == _tcscmp( lpszFileSpec, TEXT("..") ) )
+ {
+ bSkipThis = TRUE;
+ nSkipLevels += 1;
+ }
+ else if (
+ 0 == _tcscmp( lpszFileSpec, TEXT(".") ) ||
+ 0 == _tcscmp( lpszFileSpec, TEXT("\\") ) ||
+ 0 == _tcscmp( lpszFileSpec, TEXT("/") )
+ )
+ {
+ bSkipThis = TRUE;
+ }
+ else if ( nSkipLevels )
+ {
+ bSkipThis = TRUE;
+ nSkipLevels--;
+ }
+ else
+ bSkipThis = FALSE;
+
+ GetCaseCorrectPathNameEx( szPath, szPath, MAX_PATH, nSkipLevels );
+
+ PathAddBackslash( szPath );
+
+ /* Analyze parent if not only a trailing backslash was cutted but a real file spec */
+ if ( !bSkipThis )
+ {
+ WIN32_FIND_DATA aFindFileData;
+ HANDLE hFind = FindFirstFile( lpszShortPath, &aFindFileData );
+
+ if ( IsValidHandle(hFind) )
+ {
+ _tcscat( szPath, aFindFileData.cFileName[0] ? aFindFileData.cFileName : aFindFileData.cAlternateFileName );
+
+ FindClose( hFind );
+ }
+ else
+ return 0;
+ }
+ }
+ else
+ {
+ /* File specification can't be removed therefore the short path is either a drive
+ or a network share. If still levels to skip are left, the path specification
+ tries to travel below the file system root */
+ if ( nSkipLevels )
+ return 0;
+
+ _tcsupr( szPath );
+ }
+
+ _tcscpy( lpszLongPath, szPath );
+
+ return _tcslen( lpszLongPath );
+}
+
+//#####################################################
+#define WSTR_SYSTEM_ROOT_PATH L"\\\\.\\"
+
+DWORD GetCaseCorrectPathName(
+ LPCTSTR lpszShortPath, // file name
+ LPTSTR lpszLongPath, // path buffer
+ DWORD cchBuffer // size of path buffer
+)
+{
+ /* Special handling for "\\.\" as system root */
+ if ( lpszShortPath && 0 == wcscmp( lpszShortPath, WSTR_SYSTEM_ROOT_PATH ) )
+ {
+ if ( cchBuffer >= ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) )
+ {
+ wcscpy( lpszLongPath, WSTR_SYSTEM_ROOT_PATH );
+ return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1;
+ }
+ else
+ {
+ return ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1;
+ }
+ }
+ else
+ {
+ return GetCaseCorrectPathNameEx( lpszShortPath, lpszLongPath, cchBuffer, 0 );
+ }
+}
+
+//#############################################
+static sal_Bool _osl_decodeURL( rtl_String* strUTF8, rtl_uString** pstrDecodedURL )
+{
+ sal_Char *pBuffer;
+ const sal_Char *pSrcEnd;
+ const sal_Char *pSrc;
+ sal_Char *pDest;
+ sal_Int32 nSrcLen;
+ sal_Bool bValidEncoded = sal_True; /* Assume success */
+
+ /* The resulting decoded string length is shorter or equal to the source length */
+
+ nSrcLen = rtl_string_getLength(strUTF8);
+ pBuffer = reinterpret_cast<sal_Char*>(rtl_allocateMemory(nSrcLen + 1));
+
+ pDest = pBuffer;
+ pSrc = rtl_string_getStr(strUTF8);
+ pSrcEnd = pSrc + nSrcLen;
+
+ /* Now decode the URL what should result in an UTF8 string */
+ while ( bValidEncoded && pSrc < pSrcEnd )
+ {
+ switch ( *pSrc )
+ {
+ case '%':
+ {
+ sal_Char aToken[3];
+ sal_Char aChar;
+
+ pSrc++;
+ aToken[0] = *pSrc++;
+ aToken[1] = *pSrc++;
+ aToken[2] = 0;
+
+ aChar = (sal_Char)strtoul( aToken, NULL, 16 );
+
+ /* The chars are path delimiters and must not be encoded */
+
+ if ( 0 == aChar || '\\' == aChar || '/' == aChar || ':' == aChar )
+ bValidEncoded = sal_False;
+ else
+ *pDest++ = aChar;
+ }
+ break;
+ default:
+ *pDest++ = *pSrc++;
+ break;
+ }
+ }
+
+ *pDest++ = 0;
+
+ if ( bValidEncoded )
+ {
+ rtl_string2UString( pstrDecodedURL, pBuffer, rtl_str_getLength(pBuffer), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS );
+ OSL_ASSERT(*pstrDecodedURL != 0);
+ }
+
+ rtl_freeMemory( pBuffer );
+
+ return bValidEncoded;
+}
+
+//#############################################
+static void _osl_encodeURL( rtl_uString *strURL, rtl_String **pstrEncodedURL )
+{
+ /* Encode non ascii characters within the URL */
+
+ rtl_String *strUTF8 = NULL;
+ sal_Char *pszEncodedURL;
+ const sal_Char *pURLScan;
+ sal_Char *pURLDest;
+ sal_Int32 nURLScanLen;
+ sal_Int32 nURLScanCount;
+
+ rtl_uString2String( &strUTF8, rtl_uString_getStr( strURL ), rtl_uString_getLength( strURL ), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS );
+
+ pszEncodedURL = (sal_Char*) rtl_allocateMemory( (rtl_string_getLength( strUTF8 ) * 3 + 1) * sizeof(sal_Char) );
+
+ pURLDest = pszEncodedURL;
+ pURLScan = rtl_string_getStr( strUTF8 );
+ nURLScanLen = rtl_string_getLength( strUTF8 );
+ nURLScanCount = 0;
+
+ while ( nURLScanCount < nURLScanLen )
+ {
+ sal_Char cCurrent = *pURLScan;
+ switch ( cCurrent )
+ {
+ default:
+ if (!( ( cCurrent >= 'a' && cCurrent <= 'z' ) || ( cCurrent >= 'A' && cCurrent <= 'Z' ) || ( cCurrent >= '0' && cCurrent <= '9' ) ) )
+ {
+ sprintf( pURLDest, "%%%02X", (unsigned char)cCurrent );
+ pURLDest += 3;
+ break;
+ }
+ case '!':
+ case '\'':
+ case '(':
+ case ')':
+ case '*':
+ case '-':
+ case '.':
+ case '_':
+ case '~':
+ case '$':
+ case '&':
+ case '+':
+ case ',':
+ case '=':
+ case '@':
+ case ':':
+ case '/':
+ case '\\':
+ case '|':
+ *pURLDest++ = cCurrent;
+ break;
+ case 0:
+ break;
+ }
+
+ pURLScan++;
+ nURLScanCount++;
+ }
+
+ *pURLDest = 0;
+
+ rtl_string_release( strUTF8 );
+ rtl_string_newFromStr( pstrEncodedURL, pszEncodedURL );
+ rtl_freeMemory( pszEncodedURL );
+}
+
+//#############################################
+#define WSTR_SYSTEM_ROOT_PATH L"\\\\.\\"
+
+oslFileError _osl_getSystemPathFromFileURL( rtl_uString *strURL, rtl_uString **pustrPath, sal_Bool bAllowRelative )
+{
+ rtl_String *strUTF8 = NULL;
+ rtl_uString *strDecodedURL = NULL;
+ rtl_uString *strTempPath = NULL;
+ const sal_Unicode *pDecodedURL;
+ sal_uInt32 nDecodedLen;
+ sal_Bool bValidEncoded;
+ oslFileError nError = osl_File_E_INVAL; /* Assume failure */
+
+ /* If someone hasn't encoded the complete URL we convert it to UTF8 now to prevent from
+ having a mixed encoded URL later */
+
+ rtl_uString2String( &strUTF8, rtl_uString_getStr( strURL ), rtl_uString_getLength( strURL ), RTL_TEXTENCODING_UTF8, OUSTRING_TO_OSTRING_CVTFLAGS );
+
+ /* If the length of strUTF8 and strURL differs it indicates that the URL was not correct encoded */
+
+ OSL_ENSURE_FILE(
+ strUTF8->length == strURL->length ||
+ 0 != rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( strURL->buffer, strURL->length, "file:\\\\", 7 )
+ ,"osl_getSystemPathFromFileURL: \"%s\" is not encoded !!!", strURL );
+
+ bValidEncoded = _osl_decodeURL( strUTF8, &strDecodedURL );
+
+ /* Release the encoded UTF8 string */
+ rtl_string_release( strUTF8 );
+
+ if ( bValidEncoded )
+ {
+ /* Replace backslashes and pipes */
+
+ rtl_uString_newReplace( &strDecodedURL, strDecodedURL, '/', '\\' );
+ rtl_uString_newReplace( &strDecodedURL, strDecodedURL, '|', ':' );
+
+ pDecodedURL = rtl_uString_getStr( strDecodedURL );
+ nDecodedLen = rtl_uString_getLength( strDecodedURL );
+
+ /* Must start with "file://" */
+ if ( 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\", 7 ) )
+ {
+ sal_uInt32 nSkip;
+
+ if ( 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\\\", 8 ) )
+ nSkip = 8;
+ else if (
+ 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\localhost\\", 17 ) ||
+ 0 == rtl_ustr_ascii_shortenedCompareIgnoreAsciiCase_WithLength( pDecodedURL, nDecodedLen, "file:\\\\127.0.0.1\\", 17 )
+ )
+ nSkip = 17;
+ else
+ nSkip = 5;
+
+ /* Indicates local root */
+ if ( nDecodedLen == nSkip )
+ rtl_uString_newFromStr_WithLength( &strTempPath, reinterpret_cast<const sal_Unicode*>(WSTR_SYSTEM_ROOT_PATH), ELEMENTS_OF_ARRAY(WSTR_SYSTEM_ROOT_PATH) - 1 );
+ else
+ rtl_uString_newFromStr_WithLength( &strTempPath, pDecodedURL + nSkip, nDecodedLen - nSkip );
+
+ if ( IsValidFilePath( strTempPath, NULL, VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) )
+ nError = osl_File_E_None;
+ }
+ else if ( bAllowRelative ) /* This maybe a relative file URL */
+ {
+ rtl_uString_assign( &strTempPath, strDecodedURL );
+
+ if ( IsValidFilePath( strTempPath, NULL, VALIDATEPATH_ALLOW_RELATIVE | VALIDATEPATH_ALLOW_ELLIPSE, &strTempPath ) )
+ nError = osl_File_E_None;
+ }
+ /*
+ else
+ OSL_ENSURE_FILE( !nError, "osl_getSystemPathFromFileURL: \"%s\" is not an absolute FileURL !!!", strURL );
+ */
+
+ }
+
+ if ( strDecodedURL )
+ rtl_uString_release( strDecodedURL );
+
+ if ( osl_File_E_None == nError )
+ rtl_uString_assign( pustrPath, strTempPath );
+
+ if ( strTempPath )
+ rtl_uString_release( strTempPath );
+
+ /*
+ OSL_ENSURE_FILE( !nError, "osl_getSystemPathFromFileURL: \"%s\" is not a FileURL !!!", strURL );
+ */
+
+ return nError;
+}
+
+//#############################################
+oslFileError _osl_getFileURLFromSystemPath( rtl_uString* strPath, rtl_uString** pstrURL )
+{
+ oslFileError nError = osl_File_E_INVAL; /* Assume failure */
+ rtl_uString *strTempURL = NULL;
+ DWORD dwPathType = PATHTYPE_ERROR;
+
+ if (strPath)
+ dwPathType = IsValidFilePath(strPath, NULL, VALIDATEPATH_ALLOW_RELATIVE, NULL);
+
+ if (dwPathType)
+ {
+ rtl_uString *strTempPath = NULL;
+
+ /* Replace backslashes */
+ rtl_uString_newReplace( &strTempPath, strPath, '\\', '/' );
+
+ switch ( dwPathType & PATHTYPE_MASK_TYPE )
+ {
+ case PATHTYPE_RELATIVE:
+ rtl_uString_assign( &strTempURL, strTempPath );
+ nError = osl_File_E_None;
+ break;
+ case PATHTYPE_ABSOLUTE_UNC:
+ rtl_uString_newFromAscii( &strTempURL, "file:" );
+ rtl_uString_newConcat( &strTempURL, strTempURL, strTempPath );
+ nError = osl_File_E_None;
+ break;
+ case PATHTYPE_ABSOLUTE_LOCAL:
+ rtl_uString_newFromAscii( &strTempURL, "file:///" );
+ rtl_uString_newConcat( &strTempURL, strTempURL, strTempPath );
+ nError = osl_File_E_None;
+ break;
+ default:
+ break;
+ }
+
+ /* Release temp path */
+ rtl_uString_release( strTempPath );
+ }
+
+ if ( osl_File_E_None == nError )
+ {
+ rtl_String *strEncodedURL = NULL;
+
+ /* Encode the URL */
+ _osl_encodeURL( strTempURL, &strEncodedURL );
+
+ /* Provide URL via unicode string */
+ rtl_string2UString( pstrURL, rtl_string_getStr(strEncodedURL), rtl_string_getLength(strEncodedURL), RTL_TEXTENCODING_ASCII_US, OUSTRING_TO_OSTRING_CVTFLAGS );
+ OSL_ASSERT(*pstrURL != 0);
+ rtl_string_release( strEncodedURL );
+ }
+
+ /* Release temp URL */
+ if ( strTempURL )
+ rtl_uString_release( strTempURL );
+
+ /*
+ OSL_ENSURE_FILE( !nError, "osl_getFileURLFromSystemPath: \"%s\" is not a systemPath !!!", strPath );
+ */
+ return nError;
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_getFileURLFromSystemPath(
+ rtl_uString* ustrPath, rtl_uString** pustrURL )
+{
+ return _osl_getFileURLFromSystemPath( ustrPath, pustrURL );
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_getSystemPathFromFileURL(
+ rtl_uString *ustrURL, rtl_uString **pustrPath)
+{
+ return _osl_getSystemPathFromFileURL( ustrURL, pustrPath, sal_True );
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_searchFileURL(
+ rtl_uString *ustrFileName,
+ rtl_uString *ustrSystemSearchPath,
+ rtl_uString **pustrPath)
+{
+ rtl_uString *ustrUNCPath = NULL;
+ rtl_uString *ustrSysPath = NULL;
+ oslFileError error;
+
+ /* First try to interpret the file name as an URL even a relative one */
+ error = _osl_getSystemPathFromFileURL( ustrFileName, &ustrUNCPath, sal_True );
+
+ /* So far we either have an UNC path or something invalid
+ Now create a system path */
+ if ( osl_File_E_None == error )
+ error = _osl_getSystemPathFromFileURL( ustrUNCPath, &ustrSysPath, sal_True );
+
+ if ( osl_File_E_None == error )
+ {
+ DWORD nBufferLength;
+ DWORD dwResult;
+ LPTSTR lpBuffer = NULL;
+ LPTSTR lpszFilePart;
+
+ /* Repeat calling SearchPath ...
+ Start with MAX_PATH for the buffer. In most cases this
+ will be enough and does not force the loop to runtwice */
+ dwResult = MAX_PATH;
+
+ do
+ {
+ /* If search path is empty use a NULL pointer instead according to MSDN documentation of SearchPath */
+ LPCTSTR lpszSearchPath = ustrSystemSearchPath && ustrSystemSearchPath->length ? reinterpret_cast<LPCTSTR>(ustrSystemSearchPath->buffer) : NULL;
+ LPCTSTR lpszSearchFile = reinterpret_cast<LPCTSTR>(ustrSysPath->buffer);
+
+ /* Allocate space for buffer according to previous returned count of required chars */
+ /* +1 is not neccessary if we follow MSDN documentation but for robustness we do so */
+ nBufferLength = dwResult + 1;
+ lpBuffer = lpBuffer ?
+ reinterpret_cast<LPTSTR>(rtl_reallocateMemory(lpBuffer, nBufferLength * sizeof(TCHAR))) :
+ reinterpret_cast<LPTSTR>(rtl_allocateMemory(nBufferLength * sizeof(TCHAR)));
+
+ dwResult = SearchPath( lpszSearchPath, lpszSearchFile, NULL, nBufferLength, lpBuffer, &lpszFilePart );
+ } while ( dwResult && dwResult >= nBufferLength );
+
+ /* ... until an error occures or buffer is large enough.
+ dwResult == nBufferLength can not happen according to documentation but lets be robust ;-) */
+
+ if ( dwResult )
+ {
+ rtl_uString_newFromStr( &ustrSysPath, reinterpret_cast<const sal_Unicode*>(lpBuffer) );
+ error = osl_getFileURLFromSystemPath( ustrSysPath, pustrPath );
+ }
+ else
+ {
+ WIN32_FIND_DATA aFindFileData;
+ HANDLE hFind;
+
+ /* Somthing went wrong, perhaps the path was absolute */
+ error = oslTranslateFileError( GetLastError() );
+
+ hFind = FindFirstFile( reinterpret_cast<LPCTSTR>(ustrSysPath->buffer), &aFindFileData );
+
+ if ( IsValidHandle(hFind) )
+ {
+ error = osl_getFileURLFromSystemPath( ustrSysPath, pustrPath );
+ FindClose( hFind );
+ }
+ }
+
+ rtl_freeMemory( lpBuffer );
+ }
+
+ if ( ustrSysPath )
+ rtl_uString_release( ustrSysPath );
+
+ if ( ustrUNCPath )
+ rtl_uString_release( ustrUNCPath );
+
+ return error;
+}
+
+//#####################################################
+
+oslFileError SAL_CALL osl_getAbsoluteFileURL( rtl_uString* ustrBaseURL, rtl_uString* ustrRelativeURL, rtl_uString** pustrAbsoluteURL )
+{
+ oslFileError eError;
+ rtl_uString *ustrRelSysPath = NULL;
+ rtl_uString *ustrBaseSysPath = NULL;
+
+ if ( ustrBaseURL && ustrBaseURL->length )
+ {
+ eError = _osl_getSystemPathFromFileURL( ustrBaseURL, &ustrBaseSysPath, sal_False );
+ OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called with relative or invalid base URL" );
+
+ eError = _osl_getSystemPathFromFileURL( ustrRelativeURL, &ustrRelSysPath, sal_True );
+ }
+ else
+ {
+ eError = _osl_getSystemPathFromFileURL( ustrRelativeURL, &ustrRelSysPath, sal_False );
+ OSL_ENSURE( osl_File_E_None == eError, "osl_getAbsoluteFileURL called with empty base URL and/or invalid relative URL" );
+ }
+
+ if ( !eError )
+ {
+ TCHAR szBuffer[MAX_PATH];
+ TCHAR szCurrentDir[MAX_PATH];
+ LPTSTR lpFilePart = NULL;
+ DWORD dwResult;
+
+/*@@@ToDo
+ Bad, bad hack, this only works if the base path
+ really exists which is not necessary according
+ to RFC2396
+ The whole FileURL implementation should be merged
+ with the rtl/uri class.
+*/
+ if ( ustrBaseSysPath )
+ {
+ osl_acquireMutex( g_CurrentDirectoryMutex );
+
+ GetCurrentDirectory( MAX_PATH, szCurrentDir );
+ SetCurrentDirectory( reinterpret_cast<LPCTSTR>(ustrBaseSysPath->buffer) );
+ }
+
+ dwResult = GetFullPathName( reinterpret_cast<LPCTSTR>(ustrRelSysPath->buffer), MAX_PATH, szBuffer, &lpFilePart );
+
+ if ( ustrBaseSysPath )
+ {
+ SetCurrentDirectory( szCurrentDir );
+
+ osl_releaseMutex( g_CurrentDirectoryMutex );
+ }
+
+ if ( dwResult )
+ {
+ if ( dwResult >= MAX_PATH )
+ eError = osl_File_E_INVAL;
+ else
+ {
+ rtl_uString *ustrAbsSysPath = NULL;
+
+ rtl_uString_newFromStr( &ustrAbsSysPath, reinterpret_cast<const sal_Unicode*>(szBuffer) );
+
+ eError = osl_getFileURLFromSystemPath( ustrAbsSysPath, pustrAbsoluteURL );
+
+ if ( ustrAbsSysPath )
+ rtl_uString_release( ustrAbsSysPath );
+ }
+ }
+ else
+ eError = oslTranslateFileError( GetLastError() );
+ }
+
+ if ( ustrBaseSysPath )
+ rtl_uString_release( ustrBaseSysPath );
+
+ if ( ustrRelSysPath )
+ rtl_uString_release( ustrRelSysPath );
+
+ return eError;
+}
+
+//#####################################################
+oslFileError SAL_CALL osl_getCanonicalName( rtl_uString *strRequested, rtl_uString **strValid )
+{
+ rtl_uString_newFromString(strValid, strRequested);
+ return osl_File_E_None;
+}
diff --git a/sal/osl/w32/file_url.h b/sal/osl/w32/file_url.h
new file mode 100644
index 000000000000..af23203fa0a7
--- /dev/null
+++ b/sal/osl/w32/file_url.h
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: file_url.h,v $
+ * $Revision: 1.0 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_OSL_FILE_URL_H
+#define INCLUDED_OSL_FILE_URL_H
+
+#include "sal/types.h"
+#include "rtl/ustring.h"
+#include "osl/file.h"
+
+#ifdef _MSC_VER
+#pragma warning(push,1)
+#endif
+
+#define WINDOWS_LEAN_AND_MEAN
+#include <windows.h>
+
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define PATHTYPE_ERROR 0
+#define PATHTYPE_RELATIVE 1
+#define PATHTYPE_ABSOLUTE_UNC 2
+#define PATHTYPE_ABSOLUTE_LOCAL 3
+#define PATHTYPE_MASK_TYPE 0xFF
+#define PATHTYPE_IS_VOLUME 0x0100
+#define PATHTYPE_IS_SERVER 0x0200
+
+#define VALIDATEPATH_NORMAL 0x0000
+#define VALIDATEPATH_ALLOW_WILDCARDS 0x0001
+#define VALIDATEPATH_ALLOW_ELLIPSE 0x0002
+#define VALIDATEPATH_ALLOW_RELATIVE 0x0004
+#define VALIDATEPATH_ALLOW_UNC 0x0008
+
+DWORD IsValidFilePath (
+ rtl_uString * path,
+ LPCTSTR * lppError,
+ DWORD dwFlags,
+ rtl_uString ** corrected
+);
+
+DWORD GetCaseCorrectPathName (
+ LPCTSTR lpszShortPath, // file name
+ LPTSTR lpszLongPath, // path buffer
+ DWORD cchBuffer // size of path buffer
+);
+
+oslFileError _osl_getSystemPathFromFileURL (
+ rtl_uString * strURL,
+ rtl_uString ** pustrPath,
+ sal_Bool bAllowRelative
+);
+
+oslFileError _osl_getFileURLFromSystemPath (
+ rtl_uString * strPath,
+ rtl_uString ** pstrURL
+);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* INCLUDED_OSL_FILE_URL_H */
diff --git a/sal/osl/w32/procimpl.cxx b/sal/osl/w32/procimpl.cxx
index 512cd3551f47..379caeb5affc 100644
--- a/sal/osl/w32/procimpl.cxx
+++ b/sal/osl/w32/procimpl.cxx
@@ -59,7 +59,7 @@
#include <string>
//#################################################
-extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle( HANDLE hFile );
+extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle( HANDLE hFile, sal_uInt32 uFlags );
//#################################################
const sal_Unicode NAME_VALUE_SEPARATOR = TEXT('=');
@@ -576,13 +576,13 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
WaitForSingleObject(pProcImpl->m_hProcess, INFINITE);
if (pProcessInputWrite)
- *pProcessInputWrite = osl_createFileHandleFromOSHandle(hInputWrite);
+ *pProcessInputWrite = osl_createFileHandleFromOSHandle(hInputWrite, osl_File_OpenFlag_Write);
if (pProcessOutputRead)
- *pProcessOutputRead = osl_createFileHandleFromOSHandle(hOutputRead);
+ *pProcessOutputRead = osl_createFileHandleFromOSHandle(hOutputRead, osl_File_OpenFlag_Read);
if (pProcessErrorRead)
- *pProcessErrorRead = osl_createFileHandleFromOSHandle(hErrorRead);
+ *pProcessErrorRead = osl_createFileHandleFromOSHandle(hErrorRead, osl_File_OpenFlag_Read);
return osl_Process_E_None;
}
diff --git a/sal/osl/w32/tempfile.cxx b/sal/osl/w32/tempfile.cxx
new file mode 100644
index 000000000000..6c591eae8972
--- /dev/null
+++ b/sal/osl/w32/tempfile.cxx
@@ -0,0 +1,279 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: file.cxx,v $
+ * $Revision: 1.0 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define UNICODE
+#define _UNICODE
+#define _WIN32_WINNT_0x0500
+#include "systools/win32/uwinapi.h"
+
+#include "osl/file.h"
+
+#include "file_error.h"
+#include "file_url.h"
+
+#include "osl/diagnose.h"
+
+#include <malloc.h>
+#include <tchar.h>
+
+//#####################################################
+#define ELEMENTS_OF_ARRAY(arr) (sizeof(arr)/(sizeof((arr)[0])))
+
+// Allocate n number of t's on the stack return a pointer to it in p
+#ifdef __MINGW32__
+#define STACK_ALLOC(p, t, n) (p) = reinterpret_cast<t*>(_alloca((n)*sizeof(t)));
+#else
+#define STACK_ALLOC(p, t, n) __try {(p) = reinterpret_cast<t*>(_alloca((n)*sizeof(t)));} \
+ __except(EXCEPTION_EXECUTE_HANDLER) {(p) = 0;}
+#endif
+
+extern "C" oslFileHandle SAL_CALL osl_createFileHandleFromOSHandle(HANDLE hFile, sal_uInt32 uFlags);
+
+//#####################################################
+// Temp file functions
+//#####################################################
+
+static oslFileError osl_setup_base_directory_impl_(
+ rtl_uString* pustrDirectoryURL,
+ rtl_uString** ppustr_base_dir)
+{
+ rtl_uString* dir_url = 0;
+ rtl_uString* dir = 0;
+ oslFileError error = osl_File_E_None;
+
+ if (pustrDirectoryURL)
+ rtl_uString_assign(&dir_url, pustrDirectoryURL);
+ else
+ error = osl_getTempDirURL(&dir_url);
+
+ if (osl_File_E_None == error)
+ {
+ error = _osl_getSystemPathFromFileURL(dir_url, &dir, sal_False);
+ rtl_uString_release(dir_url);
+ }
+
+ if (osl_File_E_None == error )
+ {
+ rtl_uString_assign(ppustr_base_dir, dir);
+ rtl_uString_release(dir);
+ }
+
+ return error;
+}
+
+//#####################################################
+static oslFileError osl_setup_createTempFile_impl_(
+ rtl_uString* pustrDirectoryURL,
+ oslFileHandle* pHandle,
+ rtl_uString** ppustrTempFileURL,
+ rtl_uString** ppustr_base_dir,
+ sal_Bool* b_delete_on_close)
+{
+ oslFileError osl_error;
+
+ OSL_PRECOND(((0 != pHandle) || (0 != ppustrTempFileURL)), "Invalid parameter!");
+
+ if ((0 == pHandle) && (0 == ppustrTempFileURL))
+ {
+ osl_error = osl_File_E_INVAL;
+ }
+ else
+ {
+ osl_error = osl_setup_base_directory_impl_(
+ pustrDirectoryURL, ppustr_base_dir);
+
+ *b_delete_on_close = (sal_Bool)(0 == ppustrTempFileURL);
+ }
+
+ return osl_error;
+}
+
+//#####################################################
+static oslFileError osl_win32_GetTempFileName_impl_(
+ rtl_uString* base_directory, LPWSTR temp_file_name)
+{
+ oslFileError osl_error = osl_File_E_None;
+
+ if (0 == GetTempFileNameW(
+ reinterpret_cast<LPCWSTR>(rtl_uString_getStr(base_directory)),
+ L"",
+ 0,
+ temp_file_name))
+ {
+ osl_error = oslTranslateFileError(GetLastError());
+ }
+
+ return osl_error;
+}
+
+//#####################################################
+static sal_Bool osl_win32_CreateFile_impl_(
+ LPCWSTR file_name, sal_Bool b_delete_on_close, oslFileHandle* p_handle)
+{
+ DWORD flags = FILE_ATTRIBUTE_NORMAL;
+ HANDLE hFile;
+
+ OSL_ASSERT(p_handle);
+
+ if (b_delete_on_close)
+ flags |= FILE_FLAG_DELETE_ON_CLOSE;
+
+ hFile = CreateFileW(
+ file_name,
+ GENERIC_READ | GENERIC_WRITE,
+ 0,
+ NULL,
+ TRUNCATE_EXISTING,
+ flags,
+ NULL);
+
+ // @@@ ERROR HANDLING @@@
+ if (IsValidHandle(hFile))
+ *p_handle = osl_createFileHandleFromOSHandle(hFile, osl_File_OpenFlag_Read | osl_File_OpenFlag_Write);
+
+ return (sal_Bool)IsValidHandle(hFile);
+}
+
+//#############################################
+static oslFileError osl_createTempFile_impl_(
+ rtl_uString* base_directory,
+ LPWSTR tmp_name,
+ sal_Bool b_delete_on_close,
+ oslFileHandle* pHandle,
+ rtl_uString** ppustrTempFileURL)
+{
+ oslFileError osl_error;
+
+ do
+ {
+ osl_error = osl_win32_GetTempFileName_impl_(base_directory, tmp_name);
+
+ /* if file could not be opened try again */
+
+ if ((osl_File_E_None != osl_error) || (0 == pHandle) ||
+ osl_win32_CreateFile_impl_(tmp_name, b_delete_on_close, pHandle))
+ break;
+
+ } while(1); // try until success
+
+ if ((osl_File_E_None == osl_error) && !b_delete_on_close)
+ {
+ rtl_uString* pustr = 0;
+ rtl_uString_newFromStr(&pustr, reinterpret_cast<const sal_Unicode*>(tmp_name));
+ osl_getFileURLFromSystemPath(pustr, ppustrTempFileURL);
+ rtl_uString_release(pustr);
+ }
+
+ return osl_error;
+}
+
+//#############################################
+oslFileError SAL_CALL osl_createTempFile(
+ rtl_uString* pustrDirectoryURL,
+ oslFileHandle* pHandle,
+ rtl_uString** ppustrTempFileURL)
+{
+ rtl_uString* base_directory = 0;
+ LPWSTR tmp_name;
+ sal_Bool b_delete_on_close;
+ oslFileError osl_error;
+
+ osl_error = osl_setup_createTempFile_impl_(
+ pustrDirectoryURL,
+ pHandle,
+ ppustrTempFileURL,
+ &base_directory,
+ &b_delete_on_close);
+
+ if (osl_File_E_None != osl_error)
+ return osl_error;
+
+ /* allocate enough space on the stack */
+ STACK_ALLOC(tmp_name, WCHAR, (rtl_uString_getLength(base_directory) + MAX_PATH));
+
+ if (tmp_name)
+ {
+ osl_createTempFile_impl_(
+ base_directory,
+ tmp_name,
+ b_delete_on_close,
+ pHandle,
+ ppustrTempFileURL);
+ }
+ else // stack alloc failed
+ {
+ osl_error = osl_File_E_NOMEM;
+ }
+
+ if (base_directory)
+ rtl_uString_release(base_directory);
+
+ return osl_error;
+}
+
+//#############################################
+oslFileError SAL_CALL osl_getTempDirURL(rtl_uString** pustrTempDir)
+{
+ WCHAR szBuffer[MAX_PATH];
+ LPWSTR lpBuffer = szBuffer;
+ DWORD nBufferLength = ELEMENTS_OF_ARRAY(szBuffer) - 1;
+
+ DWORD nLength;
+ oslFileError error;
+
+ do
+ {
+ nLength = GetTempPathW( ELEMENTS_OF_ARRAY(szBuffer), lpBuffer );
+ if ( nLength > nBufferLength )
+ {
+ nLength++;
+ lpBuffer = reinterpret_cast<WCHAR*>(alloca( sizeof(WCHAR) * nLength ));
+ nBufferLength = nLength - 1;
+ }
+ } while ( nLength > nBufferLength );
+
+ if ( nLength )
+ {
+ rtl_uString *ustrTempPath = NULL;
+
+ if ( '\\' == lpBuffer[nLength-1] )
+ lpBuffer[nLength-1] = 0;
+
+ rtl_uString_newFromStr( &ustrTempPath, reinterpret_cast<const sal_Unicode*>(lpBuffer) );
+
+ error = osl_getFileURLFromSystemPath( ustrTempPath, pustrTempDir );
+
+ rtl_uString_release( ustrTempPath );
+ }
+ else
+ error = oslTranslateFileError( GetLastError() );
+
+ return error;
+}
diff --git a/sal/rtl/source/math.cxx b/sal/rtl/source/math.cxx
index 3f41d5a9c105..a255ca21b13a 100644
--- a/sal/rtl/source/math.cxx
+++ b/sal/rtl/source/math.cxx
@@ -79,6 +79,130 @@ static double getN10Exp( int nExp )
return 1.0;
}
+/** Approximation algorithm for erf for 0 < x < 0.65. */
+void lcl_Erf0065( double x, double& fVal )
+{
+ static const double pn[] = {
+ 1.12837916709551256,
+ 1.35894887627277916E-1,
+ 4.03259488531795274E-2,
+ 1.20339380863079457E-3,
+ 6.49254556481904354E-5
+ };
+ static const double qn[] = {
+ 1.00000000000000000,
+ 4.53767041780002545E-1,
+ 8.69936222615385890E-2,
+ 8.49717371168693357E-3,
+ 3.64915280629351082E-4
+ };
+ double fPSum = 0.0;
+ double fQSum = 0.0;
+ double fXPow = 1.0;
+ for ( unsigned int i = 0; i <= 4; ++i )
+ {
+ fPSum += pn[i]*fXPow;
+ fQSum += qn[i]*fXPow;
+ fXPow *= x*x;
+ }
+ fVal = x * fPSum / fQSum;
+}
+
+/** Approximation algorithm for erfc for 0.65 < x < 6.0. */
+void lcl_Erfc0600( double x, double& fVal )
+{
+ double fPSum = 0.0;
+ double fQSum = 0.0;
+ double fXPow = 1.0;
+ const double *pn;
+ const double *qn;
+
+ if ( x < 2.2 )
+ {
+ static const double pn22[] = {
+ 9.99999992049799098E-1,
+ 1.33154163936765307,
+ 8.78115804155881782E-1,
+ 3.31899559578213215E-1,
+ 7.14193832506776067E-2,
+ 7.06940843763253131E-3
+ };
+ static const double qn22[] = {
+ 1.00000000000000000,
+ 2.45992070144245533,
+ 2.65383972869775752,
+ 1.61876655543871376,
+ 5.94651311286481502E-1,
+ 1.26579413030177940E-1,
+ 1.25304936549413393E-2
+ };
+ pn = pn22;
+ qn = qn22;
+ }
+ else /* if ( x < 6.0 ) this is true, but the compiler does not know */
+ {
+ static const double pn60[] = {
+ 9.99921140009714409E-1,
+ 1.62356584489366647,
+ 1.26739901455873222,
+ 5.81528574177741135E-1,
+ 1.57289620742838702E-1,
+ 2.25716982919217555E-2
+ };
+ static const double qn60[] = {
+ 1.00000000000000000,
+ 2.75143870676376208,
+ 3.37367334657284535,
+ 2.38574194785344389,
+ 1.05074004614827206,
+ 2.78788439273628983E-1,
+ 4.00072964526861362E-2
+ };
+ pn = pn60;
+ qn = qn60;
+ }
+
+ for ( unsigned int i = 0; i < 6; ++i )
+ {
+ fPSum += pn[i]*fXPow;
+ fQSum += qn[i]*fXPow;
+ fXPow *= x;
+ }
+ fQSum += qn[6]*fXPow;
+ fVal = exp( -1.0*x*x )* fPSum / fQSum;
+}
+
+/** Approximation algorithm for erfc for 6.0 < x < 26.54 (but used for all
+ x > 6.0). */
+void lcl_Erfc2654( double x, double& fVal )
+{
+ static const double pn[] = {
+ 5.64189583547756078E-1,
+ 8.80253746105525775,
+ 3.84683103716117320E1,
+ 4.77209965874436377E1,
+ 8.08040729052301677
+ };
+ static const double qn[] = {
+ 1.00000000000000000,
+ 1.61020914205869003E1,
+ 7.54843505665954743E1,
+ 1.12123870801026015E2,
+ 3.73997570145040850E1
+ };
+
+ double fPSum = 0.0;
+ double fQSum = 0.0;
+ double fXPow = 1.0;
+
+ for ( unsigned int i = 0; i <= 4; ++i )
+ {
+ fPSum += pn[i]*fXPow;
+ fQSum += qn[i]*fXPow;
+ fXPow /= x*x;
+ }
+ fVal = exp(-1.0*x*x)*fPSum / (x*fQSum);
+}
namespace {
@@ -991,3 +1115,129 @@ double SAL_CALL rtl_math_atanh( double fValue ) SAL_THROW_EXTERN_C()
{
return 0.5 * rtl_math_log1p( 2.0 * fValue / (1.0-fValue) );
}
+
+
+/** Parent error function (erf) that calls different algorithms based on the
+ value of x. It takes care of cases where x is negative as erf is an odd
+ function i.e. erf(-x) = -erf(x).
+
+ Kramer, W., and Blomquist, F., 2000, Algorithms with Guaranteed Error Bounds
+ for the Error Function and the Complementary Error Function
+
+ http://www.math.uni-wuppertal.de/wrswt/literatur_en.html
+
+ @author Kohei Yoshida <kohei@openoffice.org>
+
+ @see #i55735#
+ */
+double SAL_CALL rtl_math_erf( double x ) SAL_THROW_EXTERN_C()
+{
+ if( x == 0.0 )
+ return 0.0;
+
+ bool bNegative = false;
+ if ( x < 0.0 )
+ {
+ x = fabs( x );
+ bNegative = true;
+ }
+
+ double fErf = 1.0;
+ if ( x < 1.0e-10 )
+ fErf = (double) (x*1.1283791670955125738961589031215452L);
+ else if ( x < 0.65 )
+ lcl_Erf0065( x, fErf );
+ else
+ fErf = 1.0 - rtl_math_erfc( x );
+
+ if ( bNegative )
+ fErf *= -1.0;
+
+ return fErf;
+}
+
+
+/** Parent complementary error function (erfc) that calls different algorithms
+ based on the value of x. It takes care of cases where x is negative as erfc
+ satisfies relationship erfc(-x) = 2 - erfc(x). See the comment for Erf(x)
+ for the source publication.
+
+ @author Kohei Yoshida <kohei@openoffice.org>
+
+ @see #i55735#, moved from module scaddins (#i97091#)
+
+ */
+double SAL_CALL rtl_math_erfc( double x ) SAL_THROW_EXTERN_C()
+{
+ if ( x == 0.0 )
+ return 1.0;
+
+ bool bNegative = false;
+ if ( x < 0.0 )
+ {
+ x = fabs( x );
+ bNegative = true;
+ }
+
+ double fErfc = 0.0;
+ if ( x >= 0.65 )
+ {
+ if ( x < 6.0 )
+ lcl_Erfc0600( x, fErfc );
+ else
+ lcl_Erfc2654( x, fErfc );
+ }
+ else
+ fErfc = 1.0 - rtl_math_erf( x );
+
+ if ( bNegative )
+ fErfc = 2.0 - fErfc;
+
+ return fErfc;
+}
+
+/** improved accuracy of asinh for |x| large and for x near zero
+ @see #i97605#
+ */
+double SAL_CALL rtl_math_asinh( double fX ) SAL_THROW_EXTERN_C()
+{
+ double fSign = 1.0;
+ if ( fX == 0.0 )
+ return 0.0;
+ else
+ {
+ if ( fX < 0.0 )
+ {
+ fX = - fX;
+ fSign = -1.0;
+ }
+ if ( fX < 0.125 )
+ return fSign * rtl_math_log1p( fX + fX*fX / (1.0 + sqrt( 1.0 + fX*fX)));
+ else if ( fX < 1.25e7 )
+ return fSign * log( fX + sqrt( 1.0 + fX*fX));
+ else
+ return fSign * log( 2.0*fX);
+ }
+}
+
+/** improved accuracy of acosh for x large and for x near 1
+ @see #i97605#
+ */
+double SAL_CALL rtl_math_acosh( double fX ) SAL_THROW_EXTERN_C()
+{
+ volatile double fZ = fX - 1.0;
+ if ( fX < 1.0 )
+ {
+ double fResult;
+ ::rtl::math::setNan( &fResult );
+ return fResult;
+ }
+ else if ( fX == 1.0 )
+ return 0.0;
+ else if ( fX < 1.1 )
+ return rtl_math_log1p( fZ + sqrt( fZ*fZ + 2.0*fZ));
+ else if ( fX < 1.25e7 )
+ return log( fX + sqrt( fX*fX - 1.0));
+ else
+ return log( 2.0*fX);
+}
diff --git a/sal/util/sal.map b/sal/util/sal.map
index ad063f3794d4..d5faa563ae3f 100755
--- a/sal/util/sal.map
+++ b/sal/util/sal.map
@@ -591,6 +591,10 @@ UDK_3.9 { # OOo 3.1
UDK_3.10 { # OOo 3.2
global:
rtl_logfile_hasLogFile;
+ rtl_math_erf;
+ rtl_math_erfc;
+ rtl_math_asinh;
+ rtl_math_acosh;
} UDK_3.9;
PRIVATE_1.0 {
diff --git a/sal/workben/makefile.mk b/sal/workben/makefile.mk
index 05afbbb223ea..5f20dd07bd4a 100644
--- a/sal/workben/makefile.mk
+++ b/sal/workben/makefile.mk
@@ -35,9 +35,10 @@ PRJNAME=sal
TARGET=workben
LIBTARGET=NO
TARGETTYPE=CUI
-ENABLE_EXCEPTIONS=TRUE
+#ENABLE_EXCEPTIONS=TRUE
+NO_DEFAULT_STL=YES
-TESTAPP=test_osl_getVolInfo
+#TESTAPP=test_osl_getVolInfo
#TESTAPP=test_osl_joinProcess
#TESTAPP=getlocaleinfotest
#TESTAPP=test_osl_joinProcess
@@ -45,6 +46,7 @@ TESTAPP=test_osl_getVolInfo
#TESTAPP=salstattest
#TESTAPP=saldyntest
+TESTAPP=t_readline
#TESTAPP=t_cipher
#TESTAPP=t_digest
#TESTAPP=t_random
@@ -174,6 +176,23 @@ DEF1EXPORTFILE=export.exp
.ENDIF # salstattest
#
+# t_readline
+#
+.IF "$(TESTAPP)" == "t_readline"
+
+CFILES= t_readline.c
+OBJFILES= $(OBJ)$/t_readline.obj
+
+APP1TARGET= t_readline
+APP1OBJS= $(OBJFILES)
+APP1STDLIBS=$(SALLIB)
+APP1DEPN= $(SLB)$/sal.lib
+
+APP1RPATH=UREBIN
+
+.ENDIF # t_readline
+
+#
# t_cipher
#
.IF "$(TESTAPP)" == "t_cipher"
diff --git a/sal/workben/t_layer.c b/sal/workben/t_layer.c
deleted file mode 100644
index 5ceeb7ce21e3..000000000000
--- a/sal/workben/t_layer.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: t_layer.c,v $
- * $Revision: 1.6 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include <sal/types.h>
-#include <rtl/alloc.h>
-#include <osl/diagnose.h>
-#include <osl/interlck.h>
-#ifndef _OSL_ISOCKET_H_
-#include <osl/isocket.h>
-#endif
-
-/*========================================================================
- *
- * osl/debug.c
- *
- *======================================================================*/
-/*
- * __osl_debug_create.
- */
-static oslSocketResult SAL_CALL __osl_debug_create (
- oslSocketDescriptor *socket,
- oslAddrFamily family,
- oslSocketType type,
- oslProtocol protocol)
-{
- oslSocketResult result;
-
- if (!(socket->m_lower))
- {
- oslSocketDescriptor *lower;
- lower = osl_socket_createSocketLayer (osl_socket_getSocketMethods());
- osl_socket_pushSocketLayer (socket, lower);
- }
-
- result = (socket->m_lower->m_methods->m_create)(
- socket->m_lower, family, type, protocol);
- if (!(result == osl_Socket_Ok))
- return (result);
-
- if (!(socket->m_private))
- {
- /* ... */
- }
- return (osl_Socket_Ok);
-}
-
-/*
- * __osl_debug_delete.
- */
-static void SAL_CALL __osl_debug_delete (oslSocketDescriptor *socket)
-{
- if (socket->m_private)
- {
- /* ... */
- }
- if (socket->m_lower)
- {
- (socket->m_lower->m_methods->m_delete)(socket->m_lower);
- osl_socket_deleteSocketLayer (socket->m_lower);
- }
-}
-
-/*
- * __osl_debug_getOption.
- */
-static oslSocketResult SAL_CALL __osl_debug_getOption (
- oslSocketDescriptor *socket,
- oslSocketOptionLevel level,
- oslSocketOption option,
- void *buffer,
- sal_uInt32 length)
-{
- if (level == osl_Socket_LevelSocketLayer)
- {
- /* ... */
- return (osl_Socket_Ok);
- }
-
- return (socket->m_lower->m_methods->m_getoption)(
- socket->m_lower, level, option, buffer, length);
-}
-
-/*
- * __osl_debug_setOption.
- */
-static oslSocketResult SAL_CALL __osl_debug_setOption (
- oslSocketDescriptor *socket,
- oslSocketOptionLevel level,
- oslSocketOption option,
- const void *buffer,
- sal_uInt32 length)
-{
- if (level == osl_Socket_LevelSocketLayer)
- {
- /* ... */
- return (osl_Socket_Ok);
- }
-
- return (socket->m_lower->m_methods->m_setoption)(
- socket->m_lower, level, option, buffer, length);
-}
-
-/*
- * __osl_debug_accept.
- */
-static oslSocketDescriptor* SAL_CALL __osl_debug_accept (
- oslSocketDescriptor *socket, oslSocketAddr *fromaddr)
-{
- oslSocketDescriptor *lower;
- lower = (socket->m_lower->m_methods->m_accept)(socket->m_lower, fromaddr);
- if (lower)
- {
- oslSocketDescriptor *upper;
- upper = osl_socket_createSocketLayer (socket->m_methods);
- osl_socket_pushSocketLayer (upper, lower);
- return (upper);
- }
- return ((oslSocketDescriptor*)NULL);
-}
-
-/*
- * __osl_debug_connect.
- */
-static oslSocketResult SAL_CALL __osl_debug_connect (
- oslSocketDescriptor *socket, oslSocketAddr addr)
-{
- return (socket->m_lower->m_methods->m_connect)(socket->m_lower, addr);
-}
-
-/*
- * __osl_debug_close.
- */
-static void SAL_CALL __osl_debug_close (oslSocketDescriptor *socket)
-{
- (socket->m_lower->m_methods->m_close)(socket->m_lower);
-}
-
-/*
- * __osl_shutdown.
- */
-static void SAL_CALL __osl_debug_shutdown (
- oslSocketDescriptor *socket, oslSocketDirection direction)
-{
- (socket->m_lower->m_methods->m_shutdown)(socket->m_lower, direction);
-}
-
-/*
- * __osl_debug_methods.
- */
-static oslSocketMethods __osl_debug_methods =
-{
- NULL /* initialized on demand */
-};
-
-/*
- * osl_debug_getSocketMethods.
- */
-const oslSocketMethods* SAL_CALL osl_debug_getSocketMethods (void)
-{
- static oslInterlockedCount nonce = 0;
- if (osl_incrementInterlockedCount (&nonce) == 1)
- {
- const oslSocketMethods *methods = osl_socket_getDefaultSocketMethods();
- __osl_debug_methods = *methods;
-
- __osl_debug_methods.m_create = __osl_debug_create;
- __osl_debug_methods.m_delete = __osl_debug_delete;
-
- __osl_debug_methods.m_getoption = __osl_debug_getOption;
- __osl_debug_methods.m_setoption = __osl_debug_setOption;
-
- __osl_debug_methods.m_accept = __osl_debug_accept;
- __osl_debug_methods.m_connect = __osl_debug_connect;
- __osl_debug_methods.m_close = __osl_debug_close;
-
- __osl_debug_methods.m_shutdown = __osl_debug_shutdown;
-
- osl_incrementInterlockedCount (&nonce);
- }
-
- osl_decrementInterlockedCount (&nonce);
- return (&__osl_debug_methods);
-}
-
-/*========================================================================
- *
- * osl/socket.c (physical, bottom layer).
- *
- *======================================================================*/
-#if 0 /* NYI */
-
-static oslSocketResult SAL_CALL __osl_socket_create (
- oslSocketDescriptor *socket,
- oslAddrFamily family,
- oslSocketType type,
- oslProtocol protocol)
-{
-#if OSL_DEBUG_LEVEL > 1
- const oslSocketMethods *debug = osl_debug_getSocketMethods();
- if (!(socket->m_upper || socket->m_upper->m_methods == debug))
- {
- oslSocketDescriptor *upper;
-
- upper = osl_socket_createSocketLayer (debug);
- osl_socket_pushSocketLayer (upper, socket);
-
- return (upper->m_methods->m_create)(upper, family, type, protocol);
- }
-#endif /* OSL_DEBUG_LEVEL */
- if (!(socket->m_private))
- {
- /* ... */
- socket->m_private = osl_createSocket (family, type, protocol);
- }
- return (osl_Socket_Ok);
-}
-
-#endif /* NYI */
-
-/*========================================================================
- *
- * main.
- *
- *======================================================================*/
-int SAL_CALL main (int argc, char **argv)
-{
- oslSocketDescriptor *socket;
-
- socket = osl_socket_createSocketLayer (osl_debug_getSocketMethods());
- if (socket)
- {
- oslSocketDescriptor *connection;
- oslSocketResult result;
- oslSocketAddr addr, from;
- sal_Int32 option = 1;
-
- result = osl_socket_create (
- socket,
- osl_Socket_FamilyInet,
- osl_Socket_TypeStream,
- osl_Socket_ProtocolIp);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- result = osl_socket_setOption (
- socket,
- osl_Socket_LevelSocket,
- osl_Socket_OptionReuseAddr,
- &option, sizeof(option));
- OSL_ASSERT(result == osl_Socket_Ok);
-
- addr = osl_createEmptySocketAddr (osl_Socket_FamilyInet);
- osl_setInetPortOfSocketAddr (addr, 7777);
-
- result = osl_socket_bind (socket, addr);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- result = osl_socket_listen (socket, 1);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- connection = osl_socket_accept (socket, &from);
- if (connection)
- {
- sal_Char buffer[1024];
- sal_Int32 k, n = sizeof(buffer);
- oslSocketMsgFlag flag = osl_Socket_MsgNormal;
-
- while ((k = osl_socket_recv (connection, buffer, n, flag)) > 0)
- {
- if (osl_socket_send (connection, buffer, k, flag) < 0)
- break;
- }
-
- osl_socket_close (connection);
- osl_socket_delete (connection);
-
- osl_socket_deleteSocketLayer (connection);
- }
-
- osl_socket_close (socket);
- osl_socket_delete (socket);
-
- osl_socket_deleteSocketLayer (socket);
- }
-
- return 0;
-}
-
diff --git a/sal/workben/t_readline.c b/sal/workben/t_readline.c
new file mode 100644
index 000000000000..9cbc7d39cf20
--- /dev/null
+++ b/sal/workben/t_readline.c
@@ -0,0 +1,58 @@
+/*
+ * t_readline.c
+ */
+
+#include "osl/file.h"
+
+#include "osl/diagnose.h"
+#include "rtl/ustring.h"
+#include "rtl/byteseq.h"
+
+#include <stdio.h>
+
+/* main */
+int main (int argc, char ** argv)
+{
+ if (argc > 1)
+ {
+ oslFileError result;
+ oslFileHandle hFile = 0;
+
+ rtl_uString * pSystemPath = 0;
+ rtl_uString * pFileUrl = 0;
+
+ rtl_uString_newFromAscii (&pSystemPath, argv[1]);
+
+ result = osl_getFileURLFromSystemPath (pSystemPath, &pFileUrl);
+ rtl_uString_release (pSystemPath), pSystemPath = 0;
+ if (result != osl_File_E_None)
+ return (result);
+
+ result = osl_openFile (pFileUrl, &hFile, osl_File_OpenFlag_Read);
+ rtl_uString_release (pFileUrl), pFileUrl = 0;
+ if (result == osl_File_E_None)
+ {
+ sal_Sequence * pBuffer = 0;
+ for ( ;; )
+ {
+ sal_Int32 i, n;
+
+ result = osl_readLine (hFile, &pBuffer);
+ if (result != osl_File_E_None)
+ break;
+#if 0
+ if (pBuffer->elements[0] == 0)
+ /* @@@ cannot distinguish empty line from EOF @@@ */
+ break;
+#endif
+ for (i = 0, n = pBuffer->nElements; i < n; i++)
+ printf ("%c", (char)(pBuffer->elements[i]));
+ printf("\n");
+ }
+
+ rtl_byte_sequence_release (pBuffer), pBuffer = 0;
+ (void) osl_closeFile (hFile);
+ }
+ }
+ return 0;
+}
diff --git a/sal/workben/t_tls.c b/sal/workben/t_tls.c
deleted file mode 100644
index 2f82bee0a11f..000000000000
--- a/sal/workben/t_tls.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: t_tls.c,v $
- * $Revision: 1.5 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include <sal/types.h>
-#include <rtl/alloc.h>
-#include <rtl/ustring.h>
-#include <osl/diagnose.h>
-#include <osl/file.h>
-#include <osl/interlck.h>
-#ifndef _OSL_ISOCKET_H_
-#include <osl/isocket.h>
-#endif
-
-#ifndef _OSL_TLS_H_
-#include <osl/tls.h>
-#endif
-
-#include <string.h>
-#include <stdio.h>
-
-/*========================================================================
- *
- * Internals.
- *
- *======================================================================*/
-void SAL_CALL __rtl_sequence_release (sal_Sequence *value)
-{
- if (value)
- {
- if (osl_decrementInterlockedCount (&(value->nRefCount)) == 0)
- rtl_freeMemory (value);
- }
-}
-
-void SAL_CALL __rtl_sequence_new (sal_Sequence **value, sal_Int32 length)
-{
- if (value)
- {
- __rtl_sequence_release (*value);
-
- *value = (sal_Sequence*)rtl_allocateMemory (
- SAL_SEQUENCE_HEADER_SIZE + length);
-
- (*value)->nRefCount = 1;
- (*value)->nElements = 0;
- }
-}
-
-void load_sequence (sal_Sequence **ppSequence, const sal_Char *name)
-{
- oslFileError result;
- rtl_uString *pName, *pPath;
-
- if (ppSequence)
- {
- __rtl_sequence_release (*ppSequence);
- *ppSequence = NULL;
- }
-
- pName = NULL;
- rtl_uString_newFromAscii (&pName, name);
-
- pPath = NULL;
- result = osl_searchNormalizedPath (pName, NULL, &pPath);
- if (result == osl_File_E_None)
- {
- oslFileHandle hFile;
-
- result = osl_openFile (pPath, &hFile, osl_File_OpenFlag_Read);
- if (result == osl_File_E_None)
- {
- sal_uInt64 nSize = 0, nRead = 0;
-
- osl_setFilePos (hFile, osl_Pos_End, 0);
- osl_getFilePos (hFile, &nSize);
- osl_setFilePos (hFile, osl_Pos_Absolut, 0);
-
- __rtl_sequence_new (ppSequence, (sal_Int32)nSize);
-
- osl_readFile (hFile, (*ppSequence)->elements, nSize, &nRead);
- (*ppSequence)->nElements = (sal_Int32)nRead;
- }
- osl_closeFile (hFile);
-
- rtl_uString_release (pPath);
- }
-
- rtl_uString_release (pName);
-}
-
-/*========================================================================
- *
- * main.
- *
- *======================================================================*/
-int SAL_CALL main (int argc, char **argv)
-{
- static const sal_Char p[] = "GET / HTTP/1.0\015\012\015\012";
- oslSocketDescriptor *socket;
-
-
- socket = osl_socket_createSocketLayer (osl_tls_getSocketMethods());
- if (socket)
- {
- oslSocketAddr target;
- oslSocketResult result;
- oslSocketMsgFlag flag = osl_Socket_MsgNormal;
- rtl_uString *dotted = NULL;
-
-
- rtl_uString_newFromAscii (&dotted, argv[1]);
- target = osl_createInetSocketAddr (dotted, 443);
- rtl_uString_release (dotted);
-
- result = osl_socket_create (
- socket,
- osl_Socket_FamilyInet,
- osl_Socket_TypeStream,
- osl_Socket_ProtocolIp);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- result = osl_socket_connect (socket, target);
- osl_destroySocketAddr (target);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- result = osl_socket_connect_handshake (socket, target);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- if (osl_socket_send (socket, p, strlen(p), flag) > 0)
- {
- sal_Char buffer[1024];
- sal_Int32 k, n = sizeof(buffer);
-
- while ((k = osl_socket_recv (socket, buffer, n, flag)) > 0)
- fwrite (buffer, 1, k, stdout);
- }
-
- osl_socket_shutdown (socket, osl_Socket_DirReadWrite);
- osl_socket_close (socket);
-
- osl_socket_delete (socket);
- osl_socket_deleteSocketLayer (socket);
- }
-
-
- socket = osl_socket_createSocketLayer (osl_tls_getSocketMethods());
- if (socket)
- {
- oslSocketDescriptor *connection;
- oslSocketResult result;
- oslSocketAddr addr, from;
- sal_Int32 option = 1;
- sal_Sequence *data = NULL;
-
-
- result = osl_socket_create (
- socket,
- osl_Socket_FamilyInet,
- osl_Socket_TypeStream,
- osl_Socket_ProtocolIp);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- result = osl_socket_setOption (
- socket,
- osl_Socket_LevelSocket,
- osl_Socket_OptionReuseAddr,
- &option, sizeof(option));
- OSL_ASSERT(result == osl_Socket_Ok);
-
- addr = osl_createEmptySocketAddr (osl_Socket_FamilyInet);
- osl_setInetPortOfSocketAddr (addr, 7777);
-
- result = osl_socket_bind (socket, addr);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- load_sequence (&data, "s_cert.der");
- if (data && data->nElements)
- {
- result = osl_socket_setOption (
- socket,
- osl_Socket_LevelTLS,
- osl_Socket_OptionCertificate,
- data->elements, data->nElements);
- OSL_ASSERT(result == osl_Socket_Ok);
- }
-
- load_sequence (&data, "s_pkey.der");
- if (data && data->nElements)
- {
- result = osl_socket_setOption (
- socket,
- osl_Socket_LevelTLS,
- osl_Socket_OptionPrivateKey,
- data->elements, data->nElements);
- OSL_ASSERT(result == osl_Socket_Ok);
- }
- __rtl_sequence_release (data);
-
- result = osl_socket_listen (socket, 1);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- connection = osl_socket_accept (socket, &from);
- if (connection)
- {
- sal_Char buffer[1024];
- sal_Int32 k, n = sizeof(buffer);
- oslSocketMsgFlag flag = osl_Socket_MsgNormal;
-
- result = osl_socket_accept_handshake (connection, from);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- while ((k = osl_socket_recv (connection, buffer, n, flag)) > 0)
- {
- if (osl_socket_send (connection, buffer, k, flag) < 0)
- break;
- }
-
- osl_socket_close (connection);
-
- osl_socket_delete (connection);
- osl_socket_deleteSocketLayer (connection);
- }
-
- osl_socket_delete (socket);
- osl_socket_deleteSocketLayer (socket);
- }
-
- return 0;
-}
-
diff --git a/sal/workben/t_zip.c b/sal/workben/t_zip.c
deleted file mode 100644
index 42bb819f0256..000000000000
--- a/sal/workben/t_zip.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: t_zip.c,v $
- * $Revision: 1.5 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include <sal/types.h>
-#include <rtl/ustring.h>
-#include <osl/diagnose.h>
-#include <osl/thread.h>
-#ifndef _OSL_ZSOCKET_H_
-#include <osl/zsocket.h>
-#endif
-
-#include <stdio.h>
-
-/*========================================================================
- *
- * internals.
- *
- *======================================================================*/
-void SAL_CALL clientSocketReader (void *pData)
-{
- oslSocketDescriptor *socket;
-
- socket = (oslSocketDescriptor*)pData;
- if (socket)
- {
- sal_Char buffer[128];
- sal_Int32 k, n = sizeof(buffer);
- oslSocketMsgFlag flag = osl_Socket_MsgNormal;
-
- while ((k = osl_socket_recv (socket, buffer, n, flag)) > 0)
- {
- fwrite (buffer, 1, k, stdout);
- fflush (stdout);
- }
- }
-}
-
-/*========================================================================
- *
- * main.
- *
- *======================================================================*/
-int SAL_CALL main (int argc, char **argv)
-{
- oslSocketDescriptor *socket;
-
- socket = osl_socket_createSocketLayer (osl_zlib_getSocketMethods());
- if (socket)
- {
- oslSocketAddr addr = 0;
- oslSocketResult result;
-
- result = osl_socket_create (
- socket,
- osl_Socket_FamilyInet,
- osl_Socket_TypeStream,
- osl_Socket_ProtocolIp);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- if (argc > 1)
- {
- rtl_uString *host = 0;
-
- rtl_uString_newFromAscii (&host, argv[1]);
- addr = osl_resolveHostname (host);
- rtl_uString_release (host);
- }
-
- if (addr)
- {
- sal_Char buffer[128];
- sal_Int32 k, n = sizeof(buffer);
- oslSocketMsgFlag flag = osl_Socket_MsgNormal;
- oslThread reader;
-
- osl_setInetPortOfSocketAddr (addr, 7777);
-
- result = osl_socket_connect (socket, addr);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- result = osl_socket_connect_handshake (socket, addr);
- osl_destroySocketAddr (addr);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- reader = osl_createSuspendedThread (clientSocketReader, socket);
- OSL_ASSERT(reader);
- osl_resumeThread (reader);
-
- while ((k = fread (buffer, 1, n, stdin)) > 0)
- {
- if (osl_socket_send (socket, buffer, k, flag) < 0)
- break;
- }
-
- osl_socket_shutdown (socket, osl_Socket_DirReadWrite);
- osl_socket_close (socket);
-
- osl_joinWithThread (reader);
- osl_destroyThread (reader);
- }
- else
- {
- oslSocketDescriptor *connection;
- oslSocketAddr from = 0;
- sal_Int32 option = 1;
-
- addr = osl_createEmptySocketAddr (osl_Socket_FamilyInet);
- osl_setInetPortOfSocketAddr (addr, 7777);
-
- result = osl_socket_setOption (
- socket,
- osl_Socket_LevelSocket,
- osl_Socket_OptionReuseAddr,
- &option, sizeof(option));
- OSL_ASSERT(result == osl_Socket_Ok);
-
- result = osl_socket_bind (socket, addr);
- osl_destroySocketAddr (addr);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- result = osl_socket_listen (socket, 1);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- connection = osl_socket_accept (socket, &from);
- if (connection)
- {
- sal_Char buffer[64];
- sal_Int32 k, n = sizeof(buffer);
- oslSocketMsgFlag flag = osl_Socket_MsgNormal;
-
- result = osl_socket_accept_handshake (connection, from);
- osl_destroySocketAddr (from);
- OSL_ASSERT(result == osl_Socket_Ok);
-
- while ((k = osl_socket_recv (connection, buffer, n, flag)) > 0)
- {
- if (osl_socket_send (connection, buffer, k, flag) < 0)
- break;
- }
-
- osl_socket_close (connection);
-
- osl_socket_delete (connection);
- osl_socket_deleteSocketLayer (connection);
- }
-
- osl_socket_close (socket);
- }
-
- osl_socket_delete (socket);
- osl_socket_deleteSocketLayer (socket);
- }
-
- return 0;
-}
-
diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx
index 011fafe9d6e9..518c6029ddd2 100644
--- a/stoc/source/inspect/introspection.cxx
+++ b/stoc/source/inspect/introspection.cxx
@@ -43,6 +43,7 @@
#endif
#include <osl/diagnose.h>
#include <osl/mutex.hxx>
+#include <osl/thread.h>
#include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/weak.hxx>
#include <cppuhelper/component.hxx>
@@ -1421,28 +1422,29 @@ Sequence< Reference<XIdlMethod> > ImplIntrospectionAccess::getMethods(sal_Int32
if( nConcept & MethodConcepts )
pDestMethods[ iDest++ ] = pSourceMethods[ i ];
- /*
- // Methode mit Concepts ausgeben
- const XIdlMethodRef& rxMethod = pSourceMethods[ i ];
- OUString aMethName = rxMethod->getName();
- String aNameStr = OOUStringToString(aMethName, CHARSET_SYSTEM);
- String ConceptStr;
- if( nConcept & DANGEROUS )
- ConceptStr += "DANGEROUS |";
- if( nConcept & PROPERTY )
- ConceptStr += "PROPERTY |";
- if( nConcept & LISTENER )
- ConceptStr += "LISTENER |";
- if( nConcept & ENUMERATION )
- ConceptStr += "ENUMERATION |";
- if( nConcept & NAMECONTAINER )
- ConceptStr += "NAMECONTAINER |";
- if( nConcept & INDEXCONTAINER )
- ConceptStr += "INDEXCONTAINER |";
- if( nConcept & NORMAL_IMPL )
- ConceptStr += "NORMAL_IMPL |";
- printf( "Method %ld: %s, Concepts = %s\n", i, aNameStr.GetStr(), ConceptStr.GetStr() );
- */
+ #if OSL_DEBUG_LEVEL > 0
+ static bool debug = false;
+ if ( debug )
+ {
+ // Methode mit Concepts ausgeben
+ const Reference< XIdlMethod >& rxMethod = pSourceMethods[ i ];
+ ::rtl::OString aNameStr = ::rtl::OUStringToOString( rxMethod->getName(), osl_getThreadTextEncoding() );
+ ::rtl::OString ConceptStr;
+ if( nConcept & MethodConcept::DANGEROUS )
+ ConceptStr += "DANGEROUS |";
+ if( nConcept & MethodConcept::PROPERTY )
+ ConceptStr += "PROPERTY |";
+ if( nConcept & MethodConcept::LISTENER )
+ ConceptStr += "LISTENER |";
+ if( nConcept & MethodConcept::ENUMERATION )
+ ConceptStr += "ENUMERATION |";
+ if( nConcept & MethodConcept::NAMECONTAINER )
+ ConceptStr += "NAMECONTAINER |";
+ if( nConcept & MethodConcept::INDEXCONTAINER )
+ ConceptStr += "INDEXCONTAINER |";
+ OSL_TRACE( "Method %ld: %s, Concepts = %s", i, aNameStr.getStr(), ConceptStr.getStr() );
+ }
+ #endif
}
// Auf die richtige Laenge bringen
diff --git a/store/source/lockbyte.cxx b/store/source/lockbyte.cxx
index a38aa768908d..a03628bfb740 100644
--- a/store/source/lockbyte.cxx
+++ b/store/source/lockbyte.cxx
@@ -297,7 +297,7 @@ struct FileHandle
if (result == osl_File_E_EXIST)
{
// Already existing (O_CREAT | O_EXCL).
- result = osl_openFile (aFileUrl.pData, &m_handle, osl_File_OpenFlag_Write);
+ result = osl_openFile (aFileUrl.pData, &m_handle, osl_File_OpenFlag_Read | osl_File_OpenFlag_Write);
if ((result == osl_File_E_None) && (eAccessMode == store_AccessCreate))
{
// Truncate existing file.
diff --git a/store/workben/makefile.mk b/store/workben/makefile.mk
index 334585710522..4b58d26409a0 100644
--- a/store/workben/makefile.mk
+++ b/store/workben/makefile.mk
@@ -93,11 +93,12 @@ APP3STDLIBS= $(STOREDBGLIB)
APP3STDLIBS+= $(SALLIB)
APP3DEPN= $(STOREDBGLIB)
- APP4TARGET= t_store
- APP4OBJS= $(OBJ)$/t_store.obj
- APP4STDLIBS= $(STORELIB)
- APP4STDLIBS+= $(SALLIB)
- APP4DEPN= $(SLB)$/store.lib
+APP4TARGET= t_store
+APP4OBJS= $(OBJ)$/t_store.obj
+APP4STDLIBS= $(STORELIB)
+APP4STDLIBS+= $(SALLIB)
+APP4DEPN= $(SLB)$/store.lib
+APP4RPATH= UREBIN
APP5TARGET= t_leak
APP5OBJS= $(OBJ)$/t_leak.obj
diff --git a/unoil/climaker/version.txt b/unoil/climaker/version.txt
index 867c3d411c64..4824a36ed3eb 100644
--- a/unoil/climaker/version.txt
+++ b/unoil/climaker/version.txt
@@ -29,8 +29,8 @@
#
#*************************************************************************
-CLI_OOOTYPES_NEW_VERSION=1.0.3.0
-CLI_OOOTYPES_OLD_VERSION=1.0.0.0-1.0.2.0
-CLI_OOOTYPES_POLICY_VERSION=3.0.0.0
+CLI_OOOTYPES_NEW_VERSION=1.0.4.0
+CLI_OOOTYPES_OLD_VERSION=1.0.0.0-1.0.3.0
+CLI_OOOTYPES_POLICY_VERSION=4.0.0.0
CLI_OOOTYPES_POLICY_ASSEMBLY=policy.1.0.cli_oootypes
diff --git a/ure/source/makefile.mk b/ure/source/makefile.mk
index 17dbdb322de2..9736ca597aed 100644
--- a/ure/source/makefile.mk
+++ b/ure/source/makefile.mk
@@ -35,7 +35,7 @@ TARGET := $(PRJNAME)
.INCLUDE: settings.mk
-.IF "$(OS)" == "WNT"
+.IF "$(OS)" == "WNT" || "$(OS)" == "OS2"
MY_RC = .ini
.ELSE
MY_RC = rc
diff --git a/ure/source/uretest/JavaClient.java b/ure/source/uretest/JavaClient.java
index e7b6a6ed54d2..fbb35a910c96 100644
--- a/ure/source/uretest/JavaClient.java
+++ b/ure/source/uretest/JavaClient.java
@@ -50,7 +50,7 @@ public final class JavaClient {
if (manager == null) {
throw new NullPointerException("no service manager");
}
- XBridgeFactory factory = (XBridgeFactory) UnoRuntime.queryInterface(
+ XBridgeFactory factory = UnoRuntime.queryInterface(
XBridgeFactory.class,
manager.createInstanceWithContext(
"com.sun.star.bridge.BridgeFactory", context));
@@ -63,11 +63,9 @@ public final class JavaClient {
Connector.create(context).connect(
url.getConnectionAndParametersAsString()),
null);
- Data d =
- ((XServer) UnoRuntime.queryInterface(
- XServer.class, bridge.getInstance(url.getRootOid()))).getData();
- ((XComponent) UnoRuntime.queryInterface(XComponent.class, bridge)).
- dispose();
+ Data d = UnoRuntime.queryInterface(
+ XServer.class, bridge.getInstance(url.getRootOid())).getData();
+ UnoRuntime.queryInterface(XComponent.class, bridge).dispose();
if (!d.m1.equals("Hello") || d.m2 != 42) {
throw new RuntimeException("Data object contains bad values");
}
diff --git a/xml2cmp/source/xcd/filebuff.cxx b/xml2cmp/source/xcd/filebuff.cxx
index e958c274b552..8035d697ae4d 100644
--- a/xml2cmp/source/xcd/filebuff.cxx
+++ b/xml2cmp/source/xcd/filebuff.cxx
@@ -59,11 +59,7 @@ LoadXmlFile( Buffer & o_rBuffer,
// Read file:
aXmlFile.read(o_rBuffer.Data(), (int) nBufferSize);
-#ifdef OS2 // YD eof&fail are set, so check for fail&bad
- bool ret = aXmlFile.fail() != 0;
-#else
bool ret = aXmlFile.good() != 0;
-#endif
aXmlFile.close();
return ret;
}