Compare commits

..

47 Commits
N3 ... N2

Author SHA1 Message Date
spence%netscape.com
233427693e unix build fix
git-svn-id: svn://10.0.0.236/branches/N2@24851 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-23 17:37:01 +00:00
spence%netscape.com
8a5d6cea8a unix parity
git-svn-id: svn://10.0.0.236/branches/N2@24825 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-23 08:41:00 +00:00
spence%netscape.com
060c6b2ea2 unix cleanup
git-svn-id: svn://10.0.0.236/branches/N2@24822 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-23 08:23:21 +00:00
spence%netscape.com
09b0cb9dac still bringing unix up-to-date
git-svn-id: svn://10.0.0.236/branches/N2@24646 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-22 02:41:00 +00:00
spence%netscape.com
edba634cae unix parity
git-svn-id: svn://10.0.0.236/branches/N2@24644 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-22 02:30:33 +00:00
spence%netscape.com
a7365899d1 unix parity
git-svn-id: svn://10.0.0.236/branches/N2@24639 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-22 01:14:23 +00:00
spence%netscape.com
c3389b3323 bring up-to-date on unix
git-svn-id: svn://10.0.0.236/branches/N2@24637 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-22 01:10:00 +00:00
gagan%netscape.com
718ec18100 Updates, just moving between machines...
git-svn-id: svn://10.0.0.236/branches/N2@24279 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-17 22:53:00 +00:00
gagan%netscape.com
7d190a8dd4 Removed pluggable for now...
git-svn-id: svn://10.0.0.236/branches/N2@23299 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-09 08:26:52 +00:00
gagan%netscape.com
e1ebb3e092 Changes... updates. Added nsIHeader.h
git-svn-id: svn://10.0.0.236/branches/N2@23287 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-09 05:27:33 +00:00
gagan%netscape.com
59705f110a Updates.
git-svn-id: svn://10.0.0.236/branches/N2@23286 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-09 05:27:07 +00:00
gagan%netscape.com
10d067c837 Added HTTP specific files for the pluggable protocols architecture. Made changes from IID() to GetIID() function. Other misc. errors etc.
git-svn-id: svn://10.0.0.236/branches/N2@23223 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-08 23:52:00 +00:00
gagan%netscape.com
0995f00878 The new files for pluggable HTTP. These would eventually go under mozilla/network/pluggable/http but are here till DP's autoregistration code
gets in for HTTP.


git-svn-id: svn://10.0.0.236/branches/N2@23222 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-08 23:49:55 +00:00
spence%netscape.com
44c6ee7bd0 make unix build with new netlib changes
git-svn-id: svn://10.0.0.236/branches/N2@22550 18797224-902f-48f8-a5cc-f745e15eee43
1999-03-02 08:52:18 +00:00
gagan%netscape.com
6b475c2062 Makefiles for about:protocol.
git-svn-id: svn://10.0.0.236/branches/N2@22044 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-26 03:38:56 +00:00
gagan%netscape.com
6445d6fc19 Some diff...
git-svn-id: svn://10.0.0.236/branches/N2@22032 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-26 02:34:56 +00:00
gagan%netscape.com
504987c7f8 Added pluggable protocols directory. Eventually the protocols directory will go away.
git-svn-id: svn://10.0.0.236/branches/N2@22031 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-26 02:32:22 +00:00
gagan%netscape.com
3c3c9de879 Added pluggable dir structure. Eventually this will replace the protocol
tree. First checkin.


git-svn-id: svn://10.0.0.236/branches/N2@22030 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-26 02:31:09 +00:00
gagan%netscape.com
4fb4cdbaf9 Changes related to calling nsIProtocolInstance, and added error handling codes.
git-svn-id: svn://10.0.0.236/branches/N2@22015 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-26 01:51:02 +00:00
gagan%netscape.com
6c56d63c2b First checkin of nsIProtocolInstance.
git-svn-id: svn://10.0.0.236/branches/N2@21819 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-25 01:35:28 +00:00
gagan%netscape.com
6360bf628f Changes...
git-svn-id: svn://10.0.0.236/branches/N2@21818 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-25 01:34:58 +00:00
gagan%netscape.com
17afc12ff5 More changes...
git-svn-id: svn://10.0.0.236/branches/N2@21817 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-25 01:34:32 +00:00
gagan%netscape.com
d2c8923434 Debug method...
git-svn-id: svn://10.0.0.236/branches/N2@21707 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-24 05:44:01 +00:00
gagan%netscape.com
d962f6c931 Some fixes and changed the parsing routine to use PL_strpbrk.
git-svn-id: svn://10.0.0.236/branches/N2@21703 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-24 04:57:40 +00:00
gagan%netscape.com
c467d95fcc URL parsing related work.
git-svn-id: svn://10.0.0.236/branches/N2@20920 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-17 08:35:12 +00:00
gagan%netscape.com
7d6ab18c04 Removed local nsFileStream.cpp.
git-svn-id: svn://10.0.0.236/branches/N2@20882 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-17 04:23:49 +00:00
gagan%netscape.com
2267821c34 Removed local nsFileStream.h we are now using mozilla/base/public/nsFileStream.h
git-svn-id: svn://10.0.0.236/branches/N2@20881 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-17 04:18:56 +00:00
spence%netscape.com
f652521f1f replacement of nsFileStream
git-svn-id: svn://10.0.0.236/branches/N2@20880 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-17 04:12:27 +00:00
gagan%netscape.com
4df60ddcca Minor tweaks to build on windows.
git-svn-id: svn://10.0.0.236/branches/N2@20864 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-17 03:15:35 +00:00
gagan%netscape.com
2a952c444d Ah... more of TheManager changes.
git-svn-id: svn://10.0.0.236/branches/N2@20861 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-17 02:58:48 +00:00
gagan%netscape.com
b1d8f9e682 Modified the global manager to be initialized only when somebody makes the first request for it. Possible fix for the static initialization problem. Should work.
git-svn-id: svn://10.0.0.236/branches/N2@20859 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-17 02:46:17 +00:00
spence%netscape.com
d2229d1d13 cleanup of old FileStream class
git-svn-id: svn://10.0.0.236/branches/N2@20835 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-17 00:16:19 +00:00
gagan%netscape.com
1165868b3c Updates. transfering to my desktop...
git-svn-id: svn://10.0.0.236/branches/N2@20827 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-16 22:42:10 +00:00
gagan%netscape.com
f74ec1b6ec Makefile changes for the new files.
git-svn-id: svn://10.0.0.236/branches/N2@20746 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-16 00:05:43 +00:00
gagan%netscape.com
2946bb22b6 Updates. Should compile now.
git-svn-id: svn://10.0.0.236/branches/N2@20745 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-16 00:04:30 +00:00
gagan%netscape.com
071e3adc48 First checkin of URL interfaces. Not in the build yet.
git-svn-id: svn://10.0.0.236/branches/N2@20536 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-12 05:54:58 +00:00
gagan%netscape.com
46e56a76cd New URL implementation files. Not in the build as yet. (Even for N2)
git-svn-id: svn://10.0.0.236/branches/N2@20535 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-12 05:51:23 +00:00
spence%netscape.com
7a5a6134fc resurrected
git-svn-id: svn://10.0.0.236/branches/N2@20350 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-11 03:31:54 +00:00
spence%netscape.com
57dafff70d cleanup
git-svn-id: svn://10.0.0.236/branches/N2@20344 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-11 03:00:37 +00:00
(no author)
34420a2e9d This commit was manufactured by cvs2svn to create branch 'N2'.
git-svn-id: svn://10.0.0.236/branches/N2@20337 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-11 02:25:26 +00:00
spence%netscape.com
81aeb86448 updated to use mozilla/base nsFileStream
git-svn-id: svn://10.0.0.236/branches/N2@20336 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-11 02:25:25 +00:00
spence%netscape.com
5586abebc4 updated NU_CACHE to use mozilla/base nsFileStream class
git-svn-id: svn://10.0.0.236/branches/N2@20333 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-11 01:58:11 +00:00
spence%netscape.com
76c32f445f updated to use mozilla/base nsFileStream; changed name to avoid confusion
git-svn-id: svn://10.0.0.236/branches/N2@20309 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-11 00:25:41 +00:00
spence%netscape.com
ca07152e56 removed bogosity that broke NU_CACHE on unix
git-svn-id: svn://10.0.0.236/branches/N2@20287 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-10 20:51:08 +00:00
spence%netscape.com
aa16a83c74 NU_CACHE build changes for Linux
git-svn-id: svn://10.0.0.236/branches/N2@19429 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-03 13:54:52 +00:00
spence%netscape.com
df7795dbf4 NU_CACHE build changes for Linux
git-svn-id: svn://10.0.0.236/branches/N2@19428 18797224-902f-48f8-a5cc-f745e15eee43
1999-02-03 13:45:53 +00:00
(no author)
74ce2dfd5d This commit was manufactured by cvs2svn to create branch 'N2'.
git-svn-id: svn://10.0.0.236/branches/N2@18827 18797224-902f-48f8-a5cc-f745e15eee43
1999-01-27 23:06:34 +00:00
4041 changed files with 117716 additions and 493299 deletions

View File

@@ -26,16 +26,17 @@ include $(DEPTH)/config/autoconf.mk
# nglayout test program. The order is important.
DIRS = \
config \
dbm \
nsprpub \
$(NULL)
ifdef MOZ_BUILD_NSPR
ifndef MOZ_NATIVE_JPEG
DIRS += \
nsprpub \
jpeg \
$(NULL)
endif
DIRS += \
dbm \
modules/libreg \
xpcom \
$(NULL)
@@ -46,28 +47,24 @@ DIRS += \
$(NULL)
endif
ifndef MOZ_NATIVE_JPEG
DIRS += \
jpeg \
$(NULL)
endif
DIRS += \
modules/libutil \
base \
intl \
sun-java \
nav-java \
js \
modules/security/freenav \
modules/libpref \
modules/libimg \
modules/oji \
modules/oji \
modules/plugin \
base \
caps \
lib/xp \
lib/libpwcac \
network \
lib/liblayer/include \
htmlparser \
expat \
gfx \
dom \
view \
@@ -76,17 +73,10 @@ DIRS += \
rdf \
webshell \
editor \
silentdl \
sun-java \
$(NULL)
silentdl
ifdef MOZ_BUILD_XPFE
DIRS += xpfe
endif
ifdef MOZ_MAIL_NEWS
DIRS += mailnews
endif
include $(topsrcdir)/config/config.mk
@@ -103,3 +93,4 @@ real_install: install
real_clobber: clobber
real_depend: depend

3
mozilla/aclocal.m4 vendored
View File

@@ -3,6 +3,5 @@ dnl Local autoconf macros used with mozilla
dnl The contents of this file are under the Public Domain.
dnl
builtin(include, build/autoconf/gtk.m4)dnl
builtin(include, build/autoconf/altoptions.m4)dnl
builtin(include, gtk.m4)dnl

View File

@@ -1,345 +0,0 @@
#! /bin/sh
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
# Reserved.
#
# allmakefiles.sh - List of all makefiles.
# Appends the list of makefiles to the variable, MAKEFILES.
# There is no need to rerun autoconf after adding makefiles.
# You only need to run configure.
#
# Unused makefiles may be commented out with '#'.
# ('#' must be the first character on the line).
# add_makefiles - Shell function to add makefiles to MAKEFILES
add_makefiles() {
while read line; do
case $line in
\#*|dnl*) ;;
*) MAKEFILES="$MAKEFILES $line" ;;
esac
done
}
if [ -z "${srcdir}" ]; then
srcdir=.
fi
add_makefiles <<END_NGMAKEFILES
Makefile
base/Makefile
base/public/Makefile
base/src/Makefile
base/src/motif/Makefile
base/src/rhapsody/Makefile
base/src/gtk/Makefile
base/tests/Makefile
config/Makefile
config/autoconf.mk
config/mkdepend/Makefile
config/mkdetect/Makefile
config/ports/Makefile
dbm/Makefile
dbm/include/Makefile
dbm/src/Makefile
dbm/tests/Makefile
dom/Makefile
dom/public/Makefile
dom/public/base/Makefile
dom/public/coreDom/Makefile
dom/public/coreEvents/Makefile
dom/public/css/Makefile
dom/public/events/Makefile
dom/public/html/Makefile
dom/src/Makefile
dom/src/base/Makefile
dom/src/build/Makefile
dom/src/coreDOM/Makefile
dom/src/css/Makefile
dom/src/events/Makefile
dom/src/html/Makefile
dom/src/jsurl/Makefile
dom/tools/Makefile
editor/Makefile
editor/public/Makefile
expat/Makefile
expat/xmlparse/Makefile
expat/xmltok/Makefile
gfx/Makefile
gfx/public/Makefile
gfx/src/Makefile
gfx/src/gtk/Makefile
gfx/src/ps/Makefile
gfx/src/motif/Makefile
gfx/src/rhapsody/Makefile
gfx/tests/Makefile
htmlparser/Makefile
htmlparser/robot/Makefile
htmlparser/src/Makefile
htmlparser/tests/Makefile
htmlparser/tests/grabpage/Makefile
htmlparser/tests/logparse/Makefile
include/Makefile
intl/Makefile
intl/uconv/Makefile
intl/uconv/public/Makefile
intl/uconv/src/Makefile
intl/uconv/tests/Makefile
intl/uconv/ucvja/Makefile
intl/uconv/ucvlatin/Makefile
intl/uconv/ucvja2/Makefile
intl/locale/Makefile
intl/locale/public/Makefile
intl/locale/src/Makefile
intl/locale/src/unix/Makefile
intl/locale/tests/Makefile
intl/lwbrk/Makefile
intl/lwbrk/src/Makefile
intl/lwbrk/public/Makefile
intl/lwbrk/tests/Makefile
intl/unicharutil/Makefile
intl/unicharutil/src/Makefile
intl/unicharutil/public/Makefile
intl/unicharutil/tests/Makefile
intl/unicharutil/tools/Makefile
intl/strres/Makefile
intl/strres/public/Makefile
intl/strres/src/Makefile
intl/strres/tests/Makefile
jpeg/Makefile
js/Makefile
js/jsd/Makefile
js/jsd/classes/Makefile
js/src/Makefile
js/src/fdlibm/Makefile
js/src/liveconnect/Makefile
js/src/liveconnect/classes/Makefile
# js/src/xpcom/Makefile
js/src/xpconnect/Makefile
js/src/xpconnect/md/Makefile
js/src/xpconnect/md/unix/Makefile
js/src/xpconnect/test/Makefile
layout/Makefile
layout/base/Makefile
layout/base/public/Makefile
layout/base/src/Makefile
layout/base/tests/Makefile
layout/build/Makefile
layout/events/Makefile
layout/events/public/Makefile
layout/events/src/Makefile
layout/html/Makefile
layout/html/base/Makefile
layout/html/base/src/Makefile
layout/html/content/Makefile
layout/html/content/public/Makefile
layout/html/content/src/Makefile
layout/html/document/Makefile
layout/html/document/src/Makefile
layout/html/forms/Makefile
layout/html/forms/public/Makefile
layout/html/forms/src/Makefile
layout/html/style/Makefile
layout/html/style/public/Makefile
layout/html/style/src/Makefile
layout/html/table/Makefile
layout/html/table/public/Makefile
layout/html/table/src/Makefile
layout/html/tests/Makefile
layout/tools/Makefile
layout/xml/Makefile
layout/xml/content/Makefile
layout/xml/content/public/Makefile
layout/xml/content/src/Makefile
layout/xml/document/Makefile
layout/xml/document/public/Makefile
layout/xml/document/src/Makefile
layout/xul/Makefile
layout/xul/base/Makefile
layout/xul/base/src/Makefile
layout/xul/content/Makefile
layout/xul/content/src/Makefile
# lib/liblayer/Makefile
# lib/liblayer/include/Makefile
# lib/liblayer/src/Makefile
lib/libpwcac/Makefile
lib/xp/Makefile
modules/libimg/Makefile
modules/libimg/classes/Makefile
modules/libimg/classes/netscape/Makefile
modules/libimg/classes/netscape/libimg/Makefile
modules/libimg/png/Makefile
modules/libimg/public/Makefile
modules/libimg/src/Makefile
modules/libpref/Makefile
modules/libpref/admin/Makefile
modules/libpref/l10n/Makefile
modules/libpref/public/Makefile
modules/libpref/src/Makefile
modules/libreg/Makefile
modules/libreg/include/Makefile
modules/libreg/src/Makefile
modules/libutil/Makefile
modules/libutil/public/Makefile
modules/libutil/src/Makefile
modules/oji/Makefile
modules/oji/public/Makefile
modules/oji/src/Makefile
modules/plugin/Makefile
modules/plugin/nglsrc/Makefile
modules/plugin/public/Makefile
modules/plugin/src/Makefile
modules/plugin/test/Makefile
modules/security/freenav/Makefile
modules/zlib/Makefile
modules/zlib/src/Makefile
nav-java/Makefile
nav-java/stubs/Makefile
nav-java/stubs/include/Makefile
nav-java/stubs/jri/Makefile
nav-java/stubs/src/Makefile
network/Makefile
network/cache/Makefile
network/cache/nu/Makefile
network/cache/nu/include/Makefile
network/cache/nu/public/Makefile
network/cache/nu/src/Makefile
network/cache/nu/tests/Makefile
network/cache/nu/tests/fftest/Makefile
network/client/Makefile
network/cnvts/Makefile
network/cstream/Makefile
network/main/Makefile
network/mimetype/Makefile
network/public/Makefile
network/module/Makefile
network/module/tests/Makefile
network/protocol/Makefile
network/protocol/about/Makefile
network/protocol/callback/Makefile
network/protocol/dataurl/Makefile
network/protocol/file/Makefile
network/protocol/ftp/Makefile
network/protocol/gopher/Makefile
network/protocol/http/Makefile
network/protocol/js/Makefile
network/protocol/ldap/Makefile
network/protocol/marimba/Makefile
network/protocol/remote/Makefile
network/protocol/sockstub/Makefile
network/util/Makefile
rdf/Makefile
rdf/base/Makefile
rdf/base/idl/Makefile
rdf/base/public/Makefile
rdf/base/src/Makefile
rdf/util/Makefile
rdf/util/public/Makefile
rdf/util/src/Makefile
rdf/build/Makefile
rdf/content/Makefile
rdf/content/public/Makefile
rdf/content/src/Makefile
rdf/datasource/Makefile
rdf/datasource/public/Makefile
rdf/datasource/src/Makefile
rdf/tests/Makefile
rdf/tests/localfile/Makefile
rdf/tests/rdfsink/Makefile
sun-java/Makefile
sun-java/stubs/Makefile
sun-java/stubs/include/Makefile
sun-java/stubs/jri/Makefile
sun-java/stubs/src/Makefile
caps/Makefile
caps/include/Makefile
caps/public/Makefile
caps/src/Makefile
view/Makefile
view/public/Makefile
view/src/Makefile
webshell/Makefile
webshell/public/Makefile
webshell/src/Makefile
webshell/tests/Makefile
webshell/tests/viewer/Makefile
webshell/tests/viewer/public/Makefile
widget/Makefile
widget/public/Makefile
widget/src/Makefile
widget/src/build/Makefile
widget/src/motif/Makefile
widget/src/rhapsody/Makefile
widget/src/gtk/Makefile
widget/src/xpwidgets/Makefile
widget/tests/Makefile
widget/tests/scribble/Makefile
widget/tests/widget/Makefile
xpcom/Makefile
xpcom/public/Makefile
xpcom/src/Makefile
xpcom/tests/Makefile
xpcom/tests/dynamic/Makefile
xpcom/tools/Makefile
xpcom/tools/xpidl/Makefile
xpcom/libxpt/Makefile
xpcom/libxpt/public/Makefile
xpcom/libxpt/src/Makefile
xpcom/libxpt/tests/Makefile
xpcom/libxpt/tools/Makefile
xpcom/libxpt/xptinfo/Makefile
xpcom/libxpt/xptinfo/public/Makefile
xpcom/libxpt/xptinfo/src/Makefile
xpcom/libxpt/xptinfo/tests/Makefile
xpcom/idl/Makefile
silentdl/Makefile
xpfe/Makefile
xpfe/AppCores/Makefile
xpfe/AppCores/public/Makefile
xpfe/AppCores/src/Makefile
xpfe/AppCores/xul/Makefile
xpfe/AppCores/idl/Makefile
xpfe/browser/Makefile
xpfe/browser/public/Makefile
xpfe/browser/src/Makefile
# xpfe/xpviewer/Makefile
# xpfe/xpviewer/src/Makefile
# xpfe/xpviewer/public/Makefile
xpfe/appshell/Makefile
xpfe/appshell/src/Makefile
xpfe/appshell/public/Makefile
xpfe/bootstrap/Makefile
xpfe/browser/Makefile
xpfe/browser/src/Makefile
# xpfe/browser/public/Makefile
END_NGMAKEFILES
if [ "$MOZ_EDITOR" ]; then
add_makefiles <<END_EDITOR_MAKEFILES
editor/base/Makefile
editor/txmgr/Makefile
editor/txmgr/public/Makefile
editor/txmgr/src/Makefile
editor/txmgr/tests/Makefile
editor/guimgr/Makefile
editor/guimgr/src/Makefile
editor/guimgr/public/Makefile
END_EDITOR_MAKEFILES
fi
if [ "$MOZ_MAIL_NEWS" ]; then
add_makefiles < ${srcdir}/mailnews/makefiles
fi

View File

@@ -22,11 +22,9 @@ srcdir = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
DIRS = public src
ifdef ENABLE_TESTS
DIRS += tests
endif
include $(topsrcdir)/config/config.mk

View File

@@ -1,21 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#define _IMPL_NS_BASE 1
#include "MacPrefix_debug.h"

View File

@@ -1,21 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#define _IMPL_NS_BASE 1
#include "MacPrefix.h"

Binary file not shown.

Binary file not shown.

View File

@@ -2,7 +2,6 @@
mozilla/base/src/mac/nsTimerMac.cpp
mozilla/base/src/nsArena.cpp
mozilla/base/src/nsAtomTable.cpp
mozilla/base/src/nsBaseDLL.cpp
mozilla/base/src/nsBTree.cpp
mozilla/base/src/nsByteBuffer.cpp
mozilla/base/src/nsCRT.cpp
@@ -11,7 +10,6 @@ mozilla/base/src/nsEscape.cpp
mozilla/base/src/nsFileSpec.cpp
mozilla/base/src/nsFileStream.cpp
mozilla/base/src/nsRBTree.cpp
mozilla/base/src/nsProperties.cpp
mozilla/base/src/nsSizeOfHandler.cpp
mozilla/base/src/nsString.cpp
mozilla/base/src/nsUnicharBuffer.cpp

View File

@@ -18,6 +18,6 @@
DEPTH=..
IGNORE_MANIFEST=1
DIRS=public src
DIRS=public src tests
include <$(DEPTH)\config\rules.mak>

View File

@@ -2,13 +2,7 @@
# This is a list of local files which get copied to the mozilla:dist:base directory
#
nsAutoLock.h
nsISizeOfHandler.h
nsFileStream.h
nsIFileStream.h
nsIStringStream.h
nsFileSpec.h
nsRepeater.h
nsIProperties.h
nsCaretProperties.h
nsSpecialSystemDirectory.h
nsRepeater.h

View File

@@ -25,16 +25,10 @@ include $(DEPTH)/config/autoconf.mk
DEFINES += -D_IMPL_NS_BASE
EXPORTS = \
nsAutoLock.h \
nsIProperties.h \
nsISizeOfHandler.h \
nsCaretProperties.h \
nsEscape.h \
nsFileSpec.h \
nsFileStream.h \
nsIFileStream.h \
nsIStringStream.h \
nsSpecialSystemDirectory.h \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

View File

@@ -20,18 +20,12 @@ IGNORE_MANIFEST=1
DEFINES = -D_IMPL_NS_BASE
EXPORTS = \
nsAutoLock.h \
nsCaretProperties.h \
nsIProperties.h \
nsISizeOfHandler.h \
nsEscape.h \
nsFileSpec.h \
nsFileStream.h \
nsIFileStream.h \
nsIStringStream.h \
nsSpecialSystemDirectory.h \
$(NULL)
EXPORTS = \
nsIProperties.h \
nsISizeOfHandler.h \
nsFileSpec.h \
nsFileStream.h \
$(NULL)
MODULE = raptor

View File

@@ -1,116 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
A stack-based lock object that makes using PRLock a bit more
convenient. It acquires the monitor when constructed, and releases
it when it goes out of scope.
For example,
class Foo {
private:
PRLock* mLock;
public:
Foo(void) {
mLock = PR_NewLock();
}
virtual ~Foo(void) {
PR_DestroyLock(mLock);
}
void ThreadSafeMethod(void) {
// we're don't hold the lock yet...
nsAutoLock lock(mLock);
// ...but now we do.
// we even can do wacky stuff like return from arbitrary places w/o
// worrying about forgetting to release the lock
if (some_weird_condition)
return;
// otherwise do some other stuff
}
void ThreadSafeBlockScope(void) {
// we're not in the lock here...
{
nsAutoLock lock(mLock);
// but we are now, at least until the block scope closes
}
// ...now we're not in the lock anymore
}
};
*/
#ifndef nsAutoLock_h__
#define nsAutoLock_h__
#include "nscore.h"
#include "prlock.h"
#include "prlog.h"
// If you ever decide that you need to add a non-inline method to this
// class, be sure to change the class declaration to "class NS_BASE
// nsAutoLock".
class nsAutoLock {
private:
PRLock* mLock;
// Not meant to be implemented. This makes it a compiler error to
// construct or assign an nsAutoLock object incorrectly.
nsAutoLock(void) {}
nsAutoLock(nsAutoLock& aLock) {}
nsAutoLock& operator =(nsAutoLock& aLock) {
return *this;
}
// Not meant to be implemented. This makes it a compiler error to
// attempt to create an nsAutoLock object on the heap.
static void* operator new(size_t size) {
return nsnull;
}
static void operator delete(void* memory) {}
public:
nsAutoLock(PRLock* aLock) : mLock(aLock) {
PR_ASSERT(mLock);
// This will assert deep in the bowels of NSPR if you attempt
// to re-enter the lock.
PR_Lock(mLock);
}
~nsAutoLock(void) {
PR_Unlock(mLock);
}
};
#endif // nsAutoLock_h__

View File

@@ -1,53 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
// this class is used to gather caret properties from the OS. It
// must be implemented by each platform that wants more than
// the generic caret properties.
class nsCaretProperties
{
public:
nsCaretProperties();
virtual ~nsCaretProperties() {}
virtual PRInt32 GetCaretWidth() { return mCaretWidth; }
virtual PRUint32 GetCaretBlinkRate() { return mBlinkRate; }
protected:
// have value for no blinking
enum {
eDefaulBlinkRate = 500, // twice a second
eDefaultCaretWidth = 20 // 20 twips = 1 pixel
};
PRInt32 mCaretWidth; // caret width in twips
PRUint32 mBlinkRate; // blink rate in milliseconds
// members for vertical placement & size?
};
NS_BASE nsCaretProperties* NewCaretProperties();

View File

@@ -22,7 +22,6 @@
#define _ESCAPE_H_
#include "prtypes.h"
#include "nscore.h"
/* valid mask values for NET_Escape() and NET_EscapedSize(). */
typedef enum {
@@ -34,20 +33,19 @@ typedef enum {
#ifdef __cplusplus
extern "C" {
#endif
NS_BASE char * nsEscape(const char * str, nsEscapeMask mask);
char * nsEscape(const char * str, nsEscapeMask mask);
/* Caller must use delete [] on the result */
NS_BASE char * nsUnescape(char * str);
char * nsUnescape(char * str);
/* decode % escaped hex codes into character values,
* modifies the parameter, returns the same buffer
*/
NS_BASE char * nsEscapeCount(const char * str, PRInt32 len, nsEscapeMask mask, PRInt32* out_len);
char * nsEscapeCount(const char * str, PRInt32 len, nsEscapeMask mask, PRInt32* out_len);
/* Like nsEscape, but if out_len is non-null, return result string length
* in *out_len, and uses len instead of NUL termination.
* Caller must use delete [] on the result.
*/
NS_BASE PRInt32 nsUnescapeCount (char * str);
PRInt32 nsUnescapeCount (char * str);
/* decode % escaped hex codes into character values,
* modifies the parameter buffer, returns the length of the result
* (result may contain \0's).

View File

@@ -24,17 +24,7 @@
//
// Classes defined:
//
// nsFilePath, nsFileURL, nsFileSpec, nsPersistentFileDescriptor
// nsDirectoryIterator. Oh, and a convenience class nsAutoCString.
//
// Q. How should I represent files at run time?
// A. Use nsFileSpec. Using char* will lose information on some platforms.
//
// Q. Then what are nsFilePath and nsFileURL for?
// A. Only when you need a char* parameter for legacy code.
//
// Q. How should I represent files in a persistent way (eg, in a disk file)?
// A. Use nsPersistentFileDescriptor. Convert to and from nsFileSpec at run time.
// nsFilePath, nsFileURL, nsNativeFileSpec.
//
// This suite provides the following services:
//
@@ -73,7 +63,7 @@
//
// Initialize a native file spec from a URL
//
// nsFileSpec fileSpec(fileURL);
// nsNativeFileSpec fileSpec(fileURL);
//
// Make the spec unique (this one has no suffix).
//
@@ -113,8 +103,6 @@
#define _FILESPEC_H_
#include "nscore.h"
#include "nsError.h"
#include "nsString.h"
//========================================================================================
// Compiler-specific macros, as needed
@@ -128,13 +116,11 @@
#define NS_NAMESPACE_PROTOTYPE
#define NS_NAMESPACE namespace
#define NS_NAMESPACE_END
#define NS_EXPLICIT explicit
#else
#define NS_NAMESPACE_PROTOTYPE static
#define NS_NAMESPACE struct
#define NS_NAMESPACE_END ;
#define NS_EXPLICIT
#endif
//=========================== End Compiler-specific macros ===============================
@@ -151,128 +137,61 @@
// Here are the allowable ways to describe a file.
//========================================================================================
class nsFileSpec; // Preferred. For i/o use nsInputFileStream, nsOutputFileStream
class nsFilePath; // This can be passed to NSPR file I/O routines, if you must.
class nsFilePath; // This can be passed to NSPR file I/O routines.
class nsFileURL;
class nsPersistentFileDescriptor; // Used for storage across program launches.
class nsNativeFileSpec;
#define kFileURLPrefix "file://"
#define kFileURLPrefixLength (7)
class nsOutputStream;
class nsInputStream;
class nsIOutputStream;
class nsIInputStream;
class nsOutputFileStream;
class nsInputFileStream;
class nsOutputConsoleStream;
class nsString;
class nsBasicOutStream;
//========================================================================================
// Conversion of native file errors to nsresult values. These are really only for use
// in the file module, clients of this interface shouldn't really need them.
// Error results returned from this interface have, in the low-order 16 bits,
// native errors that are masked to 16 bits. Assumption: a native error of 0 is success
// on all platforms. Note the way we define this using an inline function. This
// avoids multiple evaluation if people go NS_FILE_RESULT(function_call()).
#define NS_FILE_RESULT(x) ns_file_convert_result((PRInt32)x)
nsresult ns_file_convert_result(PRInt32 nativeErr);
#define NS_FILE_FAILURE NS_FILE_RESULT(-1)
//========================================================================================
class NS_BASE nsAutoCString
//
// This should be in nsString.h, but the owner would not reply to my proposal. After four
// weeks, I decided to put it in here.
//
// This is a quiet little class that acts as a sort of autoptr for
// a const char*. If you used to call nsString::ToNewCString(), just
// to pass the result a parameter list, it was a nuisance having to
// call delete [] on the result after the call. Now you can say
// nsString myStr;
// ...
// f(nsAutoCString(myStr));
// where f is declared as void f(const char*); This call will
// make a temporary char* pointer on the stack and delete[] it
// when the function returns.
//========================================================================================
{
public:
NS_EXPLICIT nsAutoCString(const nsString& other) : mCString(other.ToNewCString()) {}
virtual ~nsAutoCString();
operator const char*() const { return mCString; }
operator const char*() { return mCString; }
protected:
const char* mCString;
}; // class nsAutoCString
//========================================================================================
class NS_BASE nsFileSpec
class NS_BASE nsNativeFileSpec
// This is whatever each platform really prefers to describe files as. Declared first
// because the other two types have an embedded nsFileSpec object.
// because the other two types have an embeded nsNativeFileSpec object.
//========================================================================================
{
public:
nsFileSpec();
NS_EXPLICIT nsFileSpec(const char* inString, PRBool inCreateDirs = PR_FALSE);
NS_EXPLICIT nsFileSpec(const nsString& inString, PRBool inCreateDirs = PR_FALSE);
NS_EXPLICIT nsFileSpec(const nsFilePath& inPath);
NS_EXPLICIT nsFileSpec(const nsFileURL& inURL);
NS_EXPLICIT nsFileSpec(const nsPersistentFileDescriptor& inURL);
nsFileSpec(const nsFileSpec& inPath);
virtual ~nsFileSpec();
nsNativeFileSpec();
explicit nsNativeFileSpec(const char* inString, bool inCreateDirs = false);
explicit nsNativeFileSpec(const nsFilePath& inPath);
explicit nsNativeFileSpec(const nsFileURL& inURL);
nsNativeFileSpec(const nsNativeFileSpec& inPath);
virtual ~nsNativeFileSpec();
void operator = (const char* inPath);
void operator = (const nsString& inPath)
{
const nsAutoCString path(inPath);
*this = path;
}
void operator = (const nsFilePath& inPath);
void operator = (const nsFileURL& inURL);
void operator = (const nsFileSpec& inOther);
void operator = (const nsPersistentFileDescriptor& inOther);
void operator = (const nsNativeFileSpec& inOther);
PRBool operator ==(const nsFileSpec& inOther) const;
PRBool operator !=(const nsFileSpec& inOther) const;
operator const char* () const { return GetCString(); }
// Same as GetCString (please read the comments).
const char* GetCString() const;
// This is the only conversion to const char*
#ifndef XP_MAC
operator const char* () const { return mPath; }
// This is the only automatic conversion to const char*
// that is provided, and it allows the
// path to be "passed" to legacy code. This practice
// is VERY EVIL and should only be used to support legacy
// code. Using it guarantees bugs on Macintosh.
// The path is cached and freed by the nsFileSpec destructor
// so do not delete (or free) it.
// path to be "passed" to NSPR file routines.
#endif
#ifdef XP_MAC
// For Macintosh people, this is meant to be useful in its own right as a C++ version
// of the FSSpec struct.
nsFileSpec(
nsNativeFileSpec(
short vRefNum,
long parID,
ConstStr255Param name);
nsFileSpec(const FSSpec& inSpec)
: mSpec(inSpec), mError(NS_OK), mPath(nsnull) {}
void operator = (const FSSpec& inSpec)
{ mSpec = inSpec; mError = NS_OK; }
nsNativeFileSpec(const FSSpec& inSpec)
: mSpec(inSpec), mError(noErr) {}
operator FSSpec* () { return &mSpec; }
operator const FSSpec* const () { return &mSpec; }
operator FSSpec& () { return mSpec; }
operator const FSSpec& () const { return mSpec; }
const FSSpec& GetFSSpec() const { return mSpec; }
FSSpec& GetFSSpec() { return mSpec; }
ConstFSSpecPtr GetFSSpecPtr() const { return &mSpec; }
FSSpecPtr GetFSSpecPtr() { return &mSpec; }
OSErr Error() const { return mError; }
void MakeAliasSafe();
// Called for the spec of an alias. Copies the alias to
// a secret temp directory and modifies the spec to point
// to it. Sets mError.
void ResolveAlias(PRBool& wasAliased);
void ResolveAlias(bool& wasAliased);
// Called for the spec of an alias. Modifies the spec to
// point to the original. Sets mError.
void MakeUnique(ConstStr255Param inSuggestedLeafName);
@@ -280,23 +199,15 @@ class NS_BASE nsFileSpec
ConstStr255Param GetLeafPName() const { return mSpec.name; }
#endif // end of Macintosh utility methods.
PRBool Valid() const { return NS_SUCCEEDED(Error()); }
nsresult Error() const
{
#ifndef XP_MAC
if (!mPath && NS_SUCCEEDED(mError))
((nsFileSpec*)this)->mError = NS_FILE_FAILURE;
#endif
return mError;
}
PRBool Failed() const { return NS_FAILED(Error()); }
friend NS_BASE nsOutputStream& operator << (
nsOutputStream& s,
const nsFileSpec& spec); // THIS IS FOR DEBUGGING ONLY.
// see PersistentFileDescriptor for the real deal.
#ifdef XP_MAC
bool Valid() const { return mError == noErr; }
#else
bool Valid() const { return true; } // Fixme.
#endif // XP_MAC
friend NS_BASE nsBasicOutStream& operator << (
nsBasicOutStream& s,
const nsNativeFileSpec& spec);
//--------------------------------------------------
// Queries and path algebra. These do not modify the disk.
@@ -306,12 +217,8 @@ class NS_BASE nsFileSpec
void SetLeafName(const char* inLeafName);
// inLeafName can be a relative path, so this allows
// one kind of concatenation of "paths".
void SetLeafName(const nsString& inLeafName)
{
const nsAutoCString leafName(inLeafName);
SetLeafName(leafName);
}
void GetParent(nsFileSpec& outSpec) const;
void GetParent(nsNativeFileSpec& outSpec) const;
// Return the filespec of the parent directory. Used
// in conjunction with GetLeafName(), this lets you
// parse a path into a list of node names. Beware,
@@ -319,35 +226,8 @@ class NS_BASE nsFileSpec
// but a spec. Volumes on Macintosh can have identical
// names. Perhaps could be used for an operator --() ?
typedef PRUint32 TimeStamp; // ie nsFileSpec::TimeStamp. This is 32 bits now,
// but might change, eg, to a 64-bit class. So use the
// typedef, and use a streaming operator to convert
// to a string, so that your code won't break. It's
// none of your business what the number means. Don't
// rely on the implementation.
void GetModDate(TimeStamp& outStamp) const;
// This will return different values on different
// platforms, even for the same file (eg, on a server).
// But if the platform is constant, it will increase after
// every file modification.
PRBool ModDateChanged(const TimeStamp& oldStamp) const
{
TimeStamp newStamp;
GetModDate(newStamp);
return newStamp != oldStamp;
}
PRUint32 GetFileSize() const;
PRUint32 GetDiskSpaceAvailable() const;
nsFileSpec operator + (const char* inRelativePath) const;
nsFileSpec operator + (const nsString& inRelativePath) const
{
const nsAutoCString
relativePath(inRelativePath);
return *this + relativePath;
}
void operator += (const char* inRelativePath);
nsNativeFileSpec operator + (const char* inRelativePath) const;
void operator += (const char* inRelativePath);
// Concatenate the relative path to this directory.
// Used for constructing the filespec of a descendant.
// This must be a directory for this to work. This differs
@@ -356,70 +236,36 @@ class NS_BASE nsFileSpec
// away its leaf information, whereas this one assumes
// this is a directory, and the relative path starts
// "below" this.
void operator += (const nsString& inRelativePath)
{
const nsAutoCString relativePath(inRelativePath);
*this += relativePath;
}
void MakeUnique();
void MakeUnique(const char* inSuggestedLeafName);
void MakeUnique(const nsString& inSuggestedLeafName)
{
const nsAutoCString suggestedLeafName(inSuggestedLeafName);
MakeUnique(suggestedLeafName);
}
PRBool IsDirectory() const;
bool IsDirectory() const;
// More stringent than Exists()
PRBool IsFile() const;
bool IsFile() const;
// More stringent than Exists()
PRBool Exists() const;
bool Exists() const;
//--------------------------------------------------
// Creation and deletion of objects. These can modify the disk.
//--------------------------------------------------
void CreateDirectory(int mode = 0700 /* for unix */);
void Delete(PRBool inRecursive) const;
void Delete(bool inRecursive);
nsresult Rename(const char* inNewName); // not const: gets updated
nsresult Rename(const nsString& inNewName)
{
const nsAutoCString newName(inNewName);
return Rename(newName);
}
nsresult Copy(const nsFileSpec& inNewParentDirectory) const;
nsresult Move(const nsFileSpec& inNewParentDirectory) const;
nsresult Execute(const char* args) const;
nsresult Execute(const nsString& args) const
{
const nsAutoCString argsString(args);
return Execute(argsString);
}
protected:
#ifdef XP_MAC
OSErr GetCatInfo(CInfoPBRec& outInfo) const;
#endif
//--------------------------------------------------
// Data
//--------------------------------------------------
protected:
private:
friend class nsFilePath;
friend class nsFileURL;
friend class nsDirectoryIterator;
#ifdef XP_MAC
FSSpec mSpec;
#endif
OSErr mError;
#else
char* mPath;
nsresult mError;
}; // class nsFileSpec
// FOR HISTORICAL REASONS:
typedef nsFileSpec nsNativeFileSpec;
#endif
}; // class nsNativeFileSpec
//========================================================================================
class NS_BASE nsFileURL
@@ -430,10 +276,9 @@ class NS_BASE nsFileURL
{
public:
nsFileURL(const nsFileURL& inURL);
NS_EXPLICIT nsFileURL(const char* inString, PRBool inCreateDirs = PR_FALSE);
NS_EXPLICIT nsFileURL(const nsString& inString, PRBool inCreateDirs = PR_FALSE);
NS_EXPLICIT nsFileURL(const nsFilePath& inPath);
NS_EXPLICIT nsFileURL(const nsFileSpec& inPath);
explicit nsFileURL(const char* inString, bool inCreateDirs = false);
explicit nsFileURL(const nsFilePath& inPath);
explicit nsFileURL(const nsNativeFileSpec& inPath);
virtual ~nsFileURL();
// nsString GetString() const { return mPath; }
@@ -442,50 +287,41 @@ class NS_BASE nsFileURL
void operator = (const nsFileURL& inURL);
void operator = (const char* inString);
void operator = (const nsString& inString)
{
const nsAutoCString string(inString);
*this = string;
}
void operator = (const nsFilePath& inOther);
void operator = (const nsFileSpec& inOther);
void operator = (const nsNativeFileSpec& inOther);
operator const char* () const { return mURL; } // deprecated.
const char* GetAsString() const { return mURL; }
friend NS_BASE nsOutputStream& operator << (
nsOutputStream& s, const nsFileURL& spec);
friend NS_BASE nsBasicOutStream& operator << (
nsBasicOutStream& s, const nsFileURL& spec);
#ifdef XP_MAC
// Accessor to allow quick assignment to a mFileSpec
const nsFileSpec& GetFileSpec() const { return mFileSpec; }
// Accessor to allow quick assignment to a mNativeFileSpec
const nsNativeFileSpec& GetNativeSpec() const { return mNativeFileSpec; }
#endif
private:
// Should not be defined (only nsFilePath is to be treated as strings.
operator char* ();
protected:
operator const char* const ();
private:
friend class nsFilePath; // to allow construction of nsFilePath
char* mURL;
#ifdef XP_MAC
// Since the path on the macintosh does not uniquely specify a file (volumes
// can have the same name), stash the secret nsFileSpec, too.
nsFileSpec mFileSpec;
// can have the same name), stash the secret nsNativeFileSpec, too.
nsNativeFileSpec mNativeFileSpec;
#endif
}; // class nsFileURL
//========================================================================================
class NS_BASE nsFilePath
// This is a string that looks like "/foo/bar/mumble fish". Same as nsFileURL, but
// without the "file:// prefix", and NOT %20 ENCODED! Strings passed in must be
// valid unix-style paths in this format.
// This is a string that looks like "/foo/bar/mumble%20fish". Same as nsFileURL, but
// without the "file:// prefix".
//========================================================================================
{
public:
nsFilePath(const nsFilePath& inPath);
NS_EXPLICIT nsFilePath(const char* inString, PRBool inCreateDirs = PR_FALSE);
NS_EXPLICIT nsFilePath(const nsString& inString, PRBool inCreateDirs = PR_FALSE);
NS_EXPLICIT nsFilePath(const nsFileURL& inURL);
NS_EXPLICIT nsFilePath(const nsFileSpec& inPath);
explicit nsFilePath(const char* inString, bool inCreateDirs = false);
explicit nsFilePath(const nsFileURL& inURL);
explicit nsFilePath(const nsNativeFileSpec& inPath);
virtual ~nsFilePath();
@@ -500,18 +336,13 @@ class NS_BASE nsFilePath
void operator = (const nsFilePath& inPath);
void operator = (const char* inString);
void operator = (const nsString& inString)
{
const nsAutoCString string(inString);
*this = string;
}
void operator = (const nsFileURL& inURL);
void operator = (const nsFileSpec& inOther);
void operator = (const nsNativeFileSpec& inOther);
#ifdef XP_MAC
public:
// Accessor to allow quick assignment to a mFileSpec
const nsFileSpec& GetFileSpec() const { return mFileSpec; }
// Accessor to allow quick assignment to a mNativeFileSpec
const nsNativeFileSpec& GetNativeSpec() const { return mNativeFileSpec; }
#endif
private:
@@ -519,66 +350,26 @@ class NS_BASE nsFilePath
char* mPath;
#ifdef XP_MAC
// Since the path on the macintosh does not uniquely specify a file (volumes
// can have the same name), stash the secret nsFileSpec, too.
nsFileSpec mFileSpec;
// can have the same name), stash the secret nsNativeFileSpec, too.
nsNativeFileSpec mNativeFileSpec;
#endif
}; // class nsFilePath
//========================================================================================
class NS_BASE nsPersistentFileDescriptor
// To save information about a file's location in another file, initialize
// one of these from your nsFileSpec, and then write this out to your output stream.
// To retrieve the info, create one of these, read its value from an input stream.
// and then make an nsFileSpec from it.
//========================================================================================
{
public:
nsPersistentFileDescriptor() : mDescriptorString(nsnull) {}
// For use prior to reading in from a stream
nsPersistentFileDescriptor(const nsPersistentFileDescriptor& inPath);
virtual ~nsPersistentFileDescriptor();
void operator = (const nsPersistentFileDescriptor& inPath);
// Conversions
NS_EXPLICIT nsPersistentFileDescriptor(const nsFileSpec& inPath);
void operator = (const nsFileSpec& inPath);
nsresult Read(nsIInputStream* aStream);
nsresult Write(nsIOutputStream* aStream);
// writes the data to a file
friend NS_BASE nsInputStream& operator >> (nsInputStream&, nsPersistentFileDescriptor&);
// reads the data from a file
friend NS_BASE nsOutputStream& operator << (nsOutputStream&, const nsPersistentFileDescriptor&);
// writes the data to a file
friend class nsFileSpec;
private:
// Here are the ways to get data in and out of a file.
void GetData(void*& outData, PRInt32& outSize) const;
// DON'T FREE the returned data!
void SetData(const void* inData, PRInt32 inSize);
protected:
char* mDescriptorString;
}; // class nsPersistentFileDescriptor
//========================================================================================
class NS_BASE nsDirectoryIterator
// Example:
//
// nsFileSpec parentDir(...); // directory over whose children we shall iterate
// nsNativeFileSpec parentDir(...); // directory over whose children we shall iterate
// for (nsDirectoryIterator i(parentDir); i; i++)
// {
// // do something with (const nsFileSpec&)i
// // do something with (const nsNativeFileSpec&)i
// }
//
// or:
//
// for (nsDirectoryIterator i(parentDir, PR_FALSE); i; i--)
// for (nsDirectoryIterator i(parentDir, false); i; i--)
// {
// // do something with (const nsFileSpec&)i
// // do something with (const nsNativeFileSpec&)i
// }
//
// Currently, the only platform on which backwards iteration actually goes backwards
@@ -587,21 +378,21 @@ class NS_BASE nsDirectoryIterator
{
public:
nsDirectoryIterator(
const nsFileSpec& parent,
const nsNativeFileSpec& parent,
int iterateDirection = +1);
#ifndef XP_MAC
// Macintosh currently doesn't allocate, so needn't clean up.
virtual ~nsDirectoryIterator();
#endif
PRBool Exists() const { return mExists; }
operator bool() const { return mExists; }
nsDirectoryIterator& operator ++(); // moves to the next item, if any.
nsDirectoryIterator& operator ++(int) { return ++(*this); } // post-increment.
nsDirectoryIterator& operator --(); // moves to the previous item, if any.
nsDirectoryIterator& operator --(int) { return --(*this); } // post-decrement.
operator nsFileSpec&() { return mCurrent; }
operator nsNativeFileSpec&() { return mCurrent; }
private:
nsFileSpec mCurrent;
PRBool mExists;
nsNativeFileSpec mCurrent;
bool mExists;
#if defined(XP_UNIX)
DIR* mDir;

View File

@@ -19,26 +19,14 @@
// First checked in on 98/11/20 by John R. McMullen in the wrong directory.
// Checked in again 98/12/04.
// Polished version 98/12/08.
// Completely rewritten to integrate with nsIInputStream and nsIOutputStream (the
// xpcom stream objects.
//========================================================================================
//
// Classes defined:
//
// nsInputStream, nsOutputStream
// These are the lightweight STATICALLY LINKED wrappers for
// the xpcom objects nsIInputStream and nsIOutputstream.
// Possible uses:
// If you are implementing a function that accepts one of these xpcom
// streams, just make one of these little jobbies on the stack, and
// the handy << or >> notation can be yours.
//
// single-byte char:
//
// nsInputFileStream, nsOutputFileStream
// These are the STATICALLY LINKED wrappers for the file-related
// versions of the above.
// nsIOFileStream
// An input and output file stream attached to the same file.
//
// This suite provide the following services:
//
@@ -53,13 +41,13 @@
//
// Basic example:
//
// nsFileSpec myPath("/Development/iotest.txt");
// nsFilePath myPath("/Development/iotest.txt");
//
// nsOutputFileStream testStream(myPath);
// testStream << "Hello World" << nsEndl;
//
// 4. Requires streams to be constructed using typesafe nsFileSpec specifier
// (not the notorious and bug prone const char*), namely nsFileSpec. See
// 4. Requires streams to be constructed using typesafe nsFilePath specifier
// (not the notorious and bug prone const char*), namely nsFilePath. See
// nsFileSpec.h for more details.
//
// 5. Fixes a bug that have been there for a long time, and
@@ -85,15 +73,7 @@
#else
#include "prio.h"
#endif
#include "nsCOMPtr.h"
#include "nsIFileStream.h"
// Defined elsewhere
class nsFileSpec;
class nsString;
class nsIInputStream;
class nsIOutputStream;
#include "nsFileSpec.h"
//========================================================================================
// Compiler-specific macros, as needed
@@ -153,591 +133,200 @@ using std::ostream;
//=========================== End Compiler-specific macros ===============================
//========================================================================================
class NS_BASE nsInputStream
// This is a convenience class, for use on the STACK ("new" junkies: get detoxed first).
// Given a COM-style stream, this allows you to use the >> operators. It also acquires and
// reference counts its stream.
// Please read the comments at the top of this file
class NS_BASE nsBasicFileStream
//========================================================================================
{
public:
nsInputStream(nsIInputStream* inStream)
: mInputStream(do_QueryInterface(inStream))
, mEOF(PR_FALSE)
{}
virtual ~nsInputStream();
nsCOMPtr<nsIInputStream> GetIStream() const
{
return mInputStream;
}
char eof() const { return get_at_eof(); }
char get();
void close()
{
mInputStream->Close();
}
PRInt32 read(void* s, PRInt32 n);
nsBasicFileStream();
nsBasicFileStream(PRFileDesc* desc, int nsprMode);
nsBasicFileStream(
const nsFilePath& inFile,
int nsprMode,
PRIntn accessMode);
virtual ~nsBasicFileStream();
// Input streamers. Add more as needed (int&, unsigned int& etc). (but you have to
// add delegators to the derived classes, too, because these operators don't inherit).
nsInputStream& operator >> (char& ch);
// Support manipulators
nsInputStream& operator >> (nsInputStream& (*pf)(nsInputStream&))
inline PRBool is_open() const { return mFileDesc != 0; }
void open(
const nsFilePath& inFile,
int nsprMode,
PRIntn accessMode);
void close();
PRIntn tell() const;
void seek(PRInt32 offset) { seek(PR_SEEK_SET, offset); }
void seek(PRSeekWhence whence, PRInt32 offset);
PRBool eof() const { return mEOF; }
PRBool failed() const { return mFailed; }
// call PR_GetError() for details
protected:
PRFileDesc* GetFileDescriptor() const { return mFileDesc; }
protected:
friend class nsBasicInStream;
friend class nsBasicOutStream;
PRFileDesc* mFileDesc;
int mNSPRMode;
PRBool mFailed;
PRBool mEOF;
}; // class nsBasicFileStream
//========================================================================================
class NS_BASE nsBasicInStream
//========================================================================================
{
protected:
nsBasicInStream(nsBasicFileStream& inStream, istream* stream);
public:
nsBasicInStream& operator >> (nsBasicInStream& (*pf)(nsBasicInStream&))
{
return pf(*this);
}
}
void get(char& c);
PRInt32 read(void* s, PRInt32 n);
PRBool readline(char* s, PRInt32 n);
// Result always null-terminated
// false result indicates line was truncated
// to fit buffer, or an error occurred.
// Input streamers. Add more as needed
nsBasicInStream& operator >> (char& ch);
istream* GetStandardStream() const { return mStdStream; }
protected:
// These certainly need to be overridden, they give the best shot we can at detecting
// eof in a simple nsIInputStream.
virtual void set_at_eof(PRBool atEnd)
{
mEOF = atEnd;
}
virtual PRBool get_at_eof() const
{
return mEOF;
}
private:
nsInputStream& operator >> (char* buf); // TOO DANGEROUS. DON'T DEFINE.
// DATA
protected:
nsCOMPtr<nsIInputStream> mInputStream;
PRBool mEOF;
}; // class nsInputStream
typedef nsInputStream nsBasicInStream; // historic support for this name
nsBasicFileStream& mBase;
istream* mStdStream;
}; // class nsBasicInStream
//========================================================================================
class NS_BASE nsOutputStream
// This is a convenience class, for use on the STACK ("new" junkies, get detoxed first).
// Given a COM-style stream, this allows you to use the << operators. It also acquires and
// reference counts its stream.
// Please read the comments at the top of this file
class NS_BASE nsBasicOutStream
//========================================================================================
{
protected:
nsBasicOutStream(nsBasicFileStream& inStream, ostream* stream);
public:
nsOutputStream() {}
nsOutputStream(nsIOutputStream* inStream)
: mOutputStream(do_QueryInterface(inStream))
{}
virtual ~nsOutputStream();
nsCOMPtr<nsIOutputStream> GetIStream() const
nsBasicOutStream& operator << (nsBasicOutStream& (*pf)(nsBasicOutStream&))
{
return mOutputStream;
}
void close()
{
mOutputStream->Close();
return pf(*this);
}
void put(char c);
PRInt32 write(const void* s, PRInt32 n);
virtual void flush();
// Output streamers. Add more as needed (but you have to add delegators to the derived
// classes, too, because these operators don't inherit).
nsOutputStream& operator << (const char* buf);
nsOutputStream& operator << (char ch);
nsOutputStream& operator << (short val);
nsOutputStream& operator << (unsigned short val);
nsOutputStream& operator << (long val);
nsOutputStream& operator << (unsigned long val);
nsOutputStream& operator << (int val);
nsOutputStream& operator << (unsigned int val);
// Support manipulators
nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&))
{
return pf(*this);
}
// DATA
protected:
nsCOMPtr<nsIOutputStream> mOutputStream;
}; // class nsOutputStream
typedef nsOutputStream nsBasicOutStream; // Historic support for this name
//========================================================================================
class NS_BASE nsErrorProne
// Common (virtual) base class for remembering errors on demand
//========================================================================================
{
public:
nsErrorProne() // for delayed opening
: mResult(NS_OK)
{
}
PRBool failed() const
{
return NS_FAILED(mResult);
}
// DATA
protected:
nsresult mResult;
}; // class nsErrorProne
//========================================================================================
class NS_BASE nsFileClient
// Because COM does not allow us to write functions which return a boolean value etc,
// this class is here to take care of the tedious "declare variable then call with
// the address of the variable" chores.
//========================================================================================
: public virtual nsErrorProne
{
public:
nsFileClient(const nsCOMPtr<nsIFile>& inFile)
: mFile(do_QueryInterface(inFile))
{
}
virtual ~nsFileClient() {}
void open(
const nsFileSpec& inFile,
int nsprMode,
PRIntn accessMode)
{
if (mFile)
mResult = mFile->Open(inFile, nsprMode, accessMode);
}
PRBool is_open() const
{
PRBool result = PR_FALSE;
if (mFile)
mFile->GetIsOpen(&result);
return result;
}
PRBool is_file() const
{
return mFile ? PR_TRUE : PR_FALSE;
}
protected:
nsFileClient() // for delayed opening
{
}
// DATA
protected:
nsCOMPtr<nsIFile> mFile;
}; // class nsFileClient
//========================================================================================
class NS_BASE nsRandomAccessStoreClient
// Because COM does not allow us to write functions which return a boolean value etc,
// this class is here to take care of the tedious "declare variable then call with
// the address of the variable" chores.
//========================================================================================
: public virtual nsErrorProne
{
public:
nsRandomAccessStoreClient() // for delayed opening
{
}
nsRandomAccessStoreClient(const nsCOMPtr<nsIRandomAccessStore>& inStore)
: mStore(do_QueryInterface(inStore))
{
}
virtual ~nsRandomAccessStoreClient() {}
void flush();
void seek(PRInt32 offset)
{
seek(PR_SEEK_SET, offset);
}
// Output streamers. Add more as needed
nsBasicOutStream& operator << (const char* buf);
nsBasicOutStream& operator << (char ch);
nsBasicOutStream& operator << (short val);
nsBasicOutStream& operator << (unsigned short val);
nsBasicOutStream& operator << (long val);
nsBasicOutStream& operator << (unsigned long val);
void seek(PRSeekWhence whence, PRInt32 offset)
{
set_at_eof(PR_FALSE);
if (mStore)
mResult = mStore->Seek(whence, offset);
}
PRIntn tell()
{
PRIntn result = -1;
if (mStore)
mResult = mStore->Tell(&result);
return result;
}
ostream* GetStandardStream() const { return mStdStream; }
protected:
virtual PRBool get_at_eof() const
{
PRBool result = PR_TRUE;
if (mStore)
mStore->GetAtEOF(&result);
return result;
}
virtual void set_at_eof(PRBool atEnd)
{
if (mStore)
mStore->SetAtEOF(atEnd);
}
// DATA
protected:
nsCOMPtr<nsIRandomAccessStore> mStore;
}; // class nsRandomAccessStoreClient
//========================================================================================
class NS_BASE nsRandomAccessInputStream
// Please read the comments at the top of this file
//========================================================================================
: public nsRandomAccessStoreClient
, public nsInputStream
{
public:
nsRandomAccessInputStream(nsIInputStream* inStream)
: nsRandomAccessStoreClient(do_QueryInterface(inStream))
, nsInputStream(inStream)
{
}
PRBool readline(char* s, PRInt32 n);
// Result always null-terminated.
// Check eof() before each call.
// CAUTION: false result only indicates line was truncated
// to fit buffer, or an error occurred (OTHER THAN eof).
// Input streamers. Unfortunately, they don't inherit!
nsInputStream& operator >> (char& ch)
{ return nsInputStream::operator >>(ch); }
nsInputStream& operator >> (nsInputStream& (*pf)(nsInputStream&))
{ return nsInputStream::operator >>(pf); }
protected:
nsRandomAccessInputStream()
: nsInputStream(nsnull)
{
}
virtual PRBool get_at_eof() const
{
return nsRandomAccessStoreClient::get_at_eof();
}
virtual void set_at_eof(PRBool atEnd)
{
nsRandomAccessStoreClient::set_at_eof(atEnd);
}
}; // class nsRandomAccessInputStream
//========================================================================================
class NS_BASE nsInputStringStream
//========================================================================================
: public nsRandomAccessInputStream
{
public:
nsInputStringStream(const char* stringToRead);
nsInputStringStream(const nsString& stringToRead);
// Input streamers. Unfortunately, they don't inherit!
nsInputStream& operator >> (char& ch)
{ return nsInputStream::operator >>(ch); }
nsInputStream& operator >> (nsInputStream& (*pf)(nsInputStream&))
{ return nsInputStream::operator >>(pf); }
}; // class nsInputStringStream
nsBasicFileStream& mBase;
ostream* mStdStream;
}; // class nsBasicOutStream
//========================================================================================
class NS_BASE nsInputFileStream
// Please read the comments at the top of this file
//========================================================================================
: public nsRandomAccessInputStream
, public nsFileClient
: public nsBasicFileStream
, public nsBasicInStream
{
public:
enum { kDefaultMode = PR_RDONLY };
nsInputFileStream(nsIInputStream* inStream)
: nsRandomAccessInputStream(inStream)
, nsFileClient(do_QueryInterface(inStream))
, mFileInputStream(do_QueryInterface(inStream))
{
}
nsInputFileStream(istream* stream = CONSOLE_IN);
nsInputFileStream(
const nsFileSpec& inFile,
int nsprMode = kDefaultMode,
PRIntn accessMode = 00700); // <- OCTAL
void Open(
const nsFileSpec& inFile,
const nsFilePath& inFile,
int nsprMode = kDefaultMode,
PRIntn accessMode = 00700) // <- OCTAL
: nsBasicFileStream(inFile, nsprMode, accessMode)
, nsBasicInStream(*this, 0)
{}
void open(
const nsFilePath& inFile,
int nsprMode = kDefaultMode,
PRIntn accessMode = 00700) // <- OCTAL
{
if (mFile)
mFile->Open(inFile, nsprMode, accessMode);
nsBasicFileStream::open(inFile, nsprMode, accessMode);
}
private:
// Input streamers. Unfortunately, they don't inherit!
nsInputStream& operator >> (char& ch)
{ return nsInputStream::operator >>(ch); }
nsInputStream& operator >> (nsInputStream& (*pf)(nsInputStream&))
{ return nsInputStream::operator >>(pf); }
nsInputFileStream& operator >> (char* buf); // TOO DANGEROUS. DON'T DEFINE.
// DATA
protected:
nsCOMPtr<nsIFileInputStream> mFileInputStream;
}; // class nsInputFileStream
//========================================================================================
class NS_BASE nsRandomAccessOutputStream
// Please read the comments at the top of this file
//========================================================================================
: public nsRandomAccessStoreClient
, public nsOutputStream
{
public:
nsRandomAccessOutputStream(nsIOutputStream* inStream)
: nsRandomAccessStoreClient(do_QueryInterface(inStream))
, nsOutputStream(inStream)
{
}
// Output streamers. Unfortunately, they don't inherit!
nsOutputStream& operator << (const char* buf)
{ return nsOutputStream::operator << (buf); }
nsOutputStream& operator << (char ch)
{ return nsOutputStream::operator << (ch); }
nsOutputStream& operator << (short val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned short val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (long val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned long val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (int val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned int val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&))
{ return nsOutputStream::operator << (pf); }
protected:
nsRandomAccessOutputStream()
: nsOutputStream(nsnull)
{
}
}; // class nsRandomAccessOutputStream
//========================================================================================
class NS_BASE nsOutputStringStream
//========================================================================================
: public nsRandomAccessOutputStream
{
public:
nsOutputStringStream(char*& stringToChange);
nsOutputStringStream(nsString& stringToChange);
// Output streamers. Unfortunately, they don't inherit!
nsOutputStream& operator << (const char* buf)
{ return nsOutputStream::operator << (buf); }
nsOutputStream& operator << (char ch)
{ return nsOutputStream::operator << (ch); }
nsOutputStream& operator << (short val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned short val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (long val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned long val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (int val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned int val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&))
{ return nsOutputStream::operator << (pf); }
}; // class nsOutputStringStream
//========================================================================================
class NS_BASE nsOutputFileStream
// Please read the comments at the top of this file
//========================================================================================
: public nsRandomAccessOutputStream
, public nsFileClient
: public nsBasicFileStream
, public nsBasicOutStream
{
public:
enum { kDefaultMode = (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE) };
nsOutputFileStream() {}
nsOutputFileStream(ostream* stream = CONSOLE_OUT);
nsOutputFileStream(
const nsFileSpec& inFile,
const nsFilePath& inFile,
int nsprMode = kDefaultMode,
PRIntn accessMode = 00700) // <- OCTAL
{
nsISupports* stream;
if (NS_FAILED(NS_NewIOFileStream(
&stream,
inFile, nsprMode, accessMode)))
return;
mFile = nsQueryInterface(stream);
mOutputStream = nsQueryInterface(stream);
mStore = nsQueryInterface(stream);
mFileOutputStream = nsQueryInterface(stream);
NS_RELEASE(stream);
}
: nsBasicFileStream(inFile, nsprMode, accessMode)
, nsBasicOutStream(*this, 0)
{}
virtual void flush();
// Output streamers. Unfortunately, they don't inherit!
nsOutputStream& operator << (const char* buf)
{ return nsOutputStream::operator << (buf); }
nsOutputStream& operator << (char ch)
{ return nsOutputStream::operator << (ch); }
nsOutputStream& operator << (short val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned short val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (long val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned long val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (int val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned int val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&))
{ return nsOutputStream::operator << (pf); }
// DATA
protected:
nsCOMPtr<nsIFileOutputStream> mFileOutputStream;
inline void open(
const nsFilePath& inFile,
int nsprMode = kDefaultMode,
PRIntn accessMode = 00700) // <- OCTAL
{
nsBasicFileStream::open(inFile, nsprMode, accessMode);
}
}; // class nsOutputFileStream
//========================================================================================
class NS_BASE nsOutputConsoleStream
// Please read the comments at the top of this file
//========================================================================================
: public nsOutputFileStream
{
public:
nsOutputConsoleStream()
{
nsISupports* stream;
if (NS_FAILED(NS_NewOutputConsoleStream(&stream)))
return;
mFile = nsQueryInterface(stream);
mOutputStream = nsQueryInterface(stream);
mFileOutputStream = nsQueryInterface(stream);
NS_RELEASE(stream);
}
// Output streamers. Unfortunately, they don't inherit!
nsOutputStream& operator << (const char* buf)
{ return nsOutputStream::operator << (buf); }
nsOutputStream& operator << (char ch)
{ return nsOutputStream::operator << (ch); }
nsOutputStream& operator << (short val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned short val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (long val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned long val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (int val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned int val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&))
{ return nsOutputStream::operator << (pf); }
}; // class nsOutputConsoleStream
//========================================================================================
class NS_BASE nsIOFileStream
// Please read the comments at the top of this file
//========================================================================================
: public nsInputFileStream
, public nsOutputStream
: public nsBasicFileStream
, public nsBasicOutStream
, public nsBasicInStream
{
public:
enum { kDefaultMode = (PR_RDWR | PR_CREATE_FILE) };
nsIOFileStream(
nsIInputStream* inInputStream
, nsIOutputStream* inOutputStream)
: nsInputFileStream(inInputStream)
, nsOutputStream(inOutputStream)
, mFileOutputStream(do_QueryInterface(inOutputStream))
{
}
nsIOFileStream(
const nsFileSpec& inFile,
const nsFilePath& inFile,
int nsprMode = kDefaultMode,
PRIntn accessMode = 00700) // <- OCTAL
: nsInputFileStream(nsnull)
, nsOutputStream(nsnull)
{
nsISupports* stream;
if (NS_FAILED(NS_NewIOFileStream(
&stream,
inFile, nsprMode, accessMode)))
return;
mFile = nsQueryInterface(stream);
mStore = nsQueryInterface(stream);
mInputStream = nsQueryInterface(stream);
mOutputStream = nsQueryInterface(stream);
mFileInputStream = nsQueryInterface(stream);
mFileOutputStream = nsQueryInterface(stream);
NS_RELEASE(stream);
}
: nsBasicFileStream(inFile, nsprMode, accessMode)
, nsBasicInStream(*this, 0)
, nsBasicOutStream(*this, 0)
{}
virtual void close()
inline void open(
const nsFilePath& inFile,
int nsprMode = kDefaultMode,
PRIntn accessMode = 00700) // <- OCTAL
{
// Doesn't matter which of the two we close:
// they're hooked up to the same file.
nsInputFileStream::close();
nsBasicFileStream::open(inFile, nsprMode, accessMode);
}
// Output streamers. Unfortunately, they don't inherit!
nsOutputStream& operator << (const char* buf)
{ return nsOutputStream::operator << (buf); }
nsOutputStream& operator << (char ch)
{ return nsOutputStream::operator << (ch); }
nsOutputStream& operator << (short val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned short val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (long val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned long val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (int val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (unsigned int val)
{ return nsOutputStream::operator << (val); }
nsOutputStream& operator << (nsOutputStream& (*pf)(nsOutputStream&))
{ return nsOutputStream::operator << (pf); }
// Input streamers. Unfortunately, they don't inherit!
nsInputStream& operator >> (char& ch)
{ return nsInputStream::operator >>(ch); }
nsInputStream& operator >> (nsInputStream& (*pf)(nsInputStream&))
{ return nsInputStream::operator >>(pf); }
// DATA
protected:
nsCOMPtr<nsIFileOutputStream> mFileOutputStream;
}; // class nsIOFileStream
//========================================================================================
// Manipulators
//========================================================================================
NS_BASE nsOutputStream& nsEndl(nsOutputStream& os); // outputs and FLUSHES.
NS_BASE nsBasicOutStream& nsEndl(nsBasicOutStream& os);
#endif /* _FILESTREAM_H_ */

View File

@@ -1,147 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIFileStream_h___
#define nsIFileStream_h___
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "prio.h"
class nsFileSpec;
/* a6cf90e8-15b3-11d2-932e-00805f8add32 */
#define NS_IFILE_IID \
{ 0xa6cf90e8, 0x15b3, 0x11d2, \
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
//========================================================================================
class nsIFile
// Represents a file, and supports Open.
//========================================================================================
: public nsISupports
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IFILE_IID; return iid; }
NS_IMETHOD Open(
const nsFileSpec& inFile,
int nsprMode,
PRIntn accessMode) = 0;
// Note: Open() is only needed after
// an explicit Close(). All file streams
// are automatically opened on construction.
NS_IMETHOD GetIsOpen(PRBool* outOpen) = 0;
}; // class nsIFile
/* a6cf90e8-15b3-11d2-932e-00805f8add32 */
#define NS_IRANDOMACCESS_IID \
{ 0xa6cf90eb, 0x15b3, 0x11d2, \
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
//========================================================================================
class nsIRandomAccessStore
// Supports Seek, Tell etc.
//========================================================================================
: public nsISupports
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IRANDOMACCESS_IID; return iid; }
NS_IMETHOD Seek(PRSeekWhence whence, PRInt32 offset) = 0;
NS_IMETHOD Tell(PRIntn* outWhere) = 0;
/* "PROTECTED" */
NS_IMETHOD GetAtEOF(PRBool* outAtEOF) = 0;
NS_IMETHOD SetAtEOF(PRBool inAtEOF) = 0;
}; // class nsIRandomAccessStore
/* a6cf90e6-15b3-11d2-932e-00805f8add32 */
#define NS_IFILEINPUTSTREAM_IID \
{ 0xa6cf90e6, 0x15b3, 0x11d2, \
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
//========================================================================================
class nsIFileInputStream
// These are additional file-specific methods that files have, above what
// nsIInputStream supports. The current implementation supports both
// interfaces.
//========================================================================================
: public nsIInputStream
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IFILEINPUTSTREAM_IID; return iid; }
}; // class nsIFileInputStream
/* a6cf90e7-15b3-11d2-932e-00805f8add32 */
#define NS_IFILEOUTPUTSTREAM_IID \
{ 0xa6cf90e7, 0x15b3, 0x11d2, \
{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }
//========================================================================================
class nsIFileOutputStream
// These are additional file-specific methods that files have, above what
// nsIOutputStream supports. The current implementation supports both
// interfaces.
//========================================================================================
: public nsIOutputStream
{
public:
static const nsIID& GetIID() { static nsIID iid = NS_IFILEOUTPUTSTREAM_IID; return iid; }
NS_IMETHOD Flush() = 0;
// Forces a write to disk.
}; // class nsIFileOutputStream
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewTypicalInputFileStream(
nsISupports** aStreamResult,
const nsFileSpec& inFile
/*Default nsprMode == PR_RDONLY*/
/*Default accessmode = 0700 (octal)*/);
// Factory method to get an nsInputStream from a file, using most common options
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewOutputConsoleStream(
nsISupports** aStreamResult);
// Factory method to get an nsOutputStream to the console.
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewTypicalOutputFileStream(
nsISupports** aStreamResult, // will implement all the above interfaces
const nsFileSpec& inFile
/*default nsprMode= (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE)*/
/*Default accessMode= 0700 (octal)*/);
// Factory method to get an nsOutputStream to a file - most common case.
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewTypicalIOFileStream(
nsISupports** aStreamResult, // will implement all the above interfaces
const nsFileSpec& inFile
/*default nsprMode = (PR_RDWR | PR_CREATE_FILE)*/
/*Default accessMode = 0700 (octal)*/);
// Factory method to get an object that implements both nsIInputStream
// and nsIOutputStream, associated with a single file.
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewIOFileStream(
nsISupports** aStreamResult, // will implement all the above interfaces
const nsFileSpec& inFile,
PRInt32 nsprMode,
PRInt32 accessMode);
// Factory method to get an object that implements both nsIInputStream
// and nsIOutputStream, associated with a single file.
#endif /* nsIFileStream_h___ */

View File

@@ -1,67 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsIStringStream_h___
#define nsIStringStream_h___
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsString.h"
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewStringInputStream(
nsISupports** aStreamResult,
const nsString& aStringToRead);
// Factory method to get an nsInputStream from a string. Result will implement all the
// file stream interfaces in nsIFileStream.h
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewStringOutputStream(
nsISupports** aStreamResult,
nsString& aStringToChange);
// Factory method to get an nsOutputStream from a string. Result will implement all the
// file stream interfaces in nsIFileStream.h
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewCharInputStream(
nsISupports** aStreamResult,
const char* aStringToRead);
// Factory method to get an nsInputStream from a string. Result will implement all the
// file stream interfaces in nsIFileStream.h
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewCharOutputStream(
nsISupports** aStreamResult,
char** aStringToChange);
// Factory method to get an nsOutputStream to a string. Result will implement all the
// file stream interfaces in nsIFileStream.h
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewStringIOStream(
nsISupports** aStreamResult,
nsString& aStringToChange);
// Factory method to get an nsOutputStream to a string. Result will implement all the
// file stream interfaces in nsIFileStream.h
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewCharIOStream(
nsISupports** aStreamResult,
char** aStringToChange);
// Factory method to get an nsOutputStream to a string. Result will implement all the
// file stream interfaces in nsIFileStream.h
#endif /* nsIStringStream_h___ */

View File

@@ -19,11 +19,9 @@
#ifndef nsRepeater_h___
#define nsRepeater_h___
#include "nscore.h"
class EventRecord;
class NS_BASE Repeater {
class Repeater {
public:
Repeater();

View File

@@ -1,84 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*
* Contributors:
* Doug Turner <dougt@netscape.com>
*/
#ifndef _NSSPECIALSYSTEMDIRECTORY_H_
#define _NSSPECIALSYSTEMDIRECTORY_H_
#include "nscore.h"
#include "nsFileSpec.h"
#ifdef XP_MAC
#include "Types.h"
#endif
// SEE ALSO:
// mozilla/xpfe/appshell/public/nsFileLocations.h
class NS_BASE nsSpecialSystemDirectory : public nsFileSpec
{
public:
enum SystemDirectories
{
OS_DriveDirectory = 1
, OS_TemporaryDirectory = 2
, OS_CurrentProcessDirectory= 3
, Mac_SystemDirectory = 101
, Mac_DesktopDirectory = 102
, Mac_TrashDirectory = 103
, Mac_StartupDirectory = 104
, Mac_ShutdownDirectory = 105
, Mac_AppleMenuDirectory = 106
, Mac_ControlPanelDirectory = 107
, Mac_ExtensionDirectory = 108
, Mac_FontsDirectory = 109
, Mac_PreferencesDirectory = 110
, Mac_DocumentsDirectory = 111
, Win_SystemDirectory = 201
, Win_WindowsDirectory = 202
, Unix_LocalDirectory = 301
, Unix_LibDirectory = 302
};
//nsSpecialSystemDirectory();
nsSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory);
virtual ~nsSpecialSystemDirectory();
void operator = (SystemDirectories aSystemSystemDirectory);
#ifdef XP_MAC
void operator = (OSType folderType);
nsSpecialSystemDirectory(OSType folderType);
#endif
private:
void operator = (const char* inPath) { *(nsFileSpec*)this = inPath; }
}; // class NS_BASE nsSpecialSystemDirectory
#endif

View File

@@ -24,8 +24,6 @@ include $(DEPTH)/config/autoconf.mk
DEFINES +=-D_IMPL_NS_BASE
LOCAL_INCLUDES += -I$(topsrcdir)/base/public
DIRS = $(MOZ_TOOLKIT)
LIBRARY_NAME = raptorbase
@@ -33,7 +31,6 @@ LIBRARY_NAME = raptorbase
CPPSRCS = \
nsArena.cpp \
nsAtomTable.cpp \
nsBaseDLL.cpp \
nsBTree.cpp \
nsByteBuffer.cpp \
nsCRT.cpp \
@@ -41,16 +38,12 @@ CPPSRCS = \
nsEscape.cpp \
nsFileSpec.cpp \
nsFileStream.cpp \
nsIFileStream.cpp \
nsIStringStream.cpp \
nsProperties.cpp \
nsRBTree.cpp \
nsSizeOfHandler.cpp \
nsSizeOfHandler.cpp \
nsString.cpp \
nsUnicharBuffer.cpp \
nsUnicharInputStream.cpp \
nsVoidArray.cpp \
nsSpecialSystemDirectory.cpp\
$(NULL)
EXPORTS = \

View File

@@ -30,13 +30,10 @@ REQUIRES = xpcom raptor
DEFINES += -D_IMPL_NS_WIDGET
CPPSRCS = \
nsTimer.cpp \
nsCaretProperties.cpp \
$(NULL)
CPPSRCS = nsTimer.cpp
include $(topsrcdir)/config/config.mk
CXXFLAGS += $(TK_CFLAGS)
CFLAGS += $(TK_CFLAGS)
include $(topsrcdir)/config/rules.mk

View File

@@ -1,40 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nscore.h"
#include "nsCaretProperties.h"
//-----------------------------------------------------------------------------
nsCaretProperties::nsCaretProperties()
: mCaretWidth(eDefaultCaretWidth)
, mBlinkRate(eDefaulBlinkRate)
{
// in your platform-specific class, get data from the OS in your constructor
//mBlinkRate = 0; // don't blink the caret
}
//-----------------------------------------------------------------------------
nsCaretProperties* NewCaretProperties()
{
return new nsCaretProperties();
}

View File

@@ -131,7 +131,6 @@ TimerImpl::Init(nsITimerCallback *aCallback,
{
//printf("TimerImpl::Init called with callback only for %p\n", this);
mCallback = aCallback;
NS_ADDREF(mCallback);
// mRepeat = aRepeat;
if ((aDelay > 10000) || (aDelay < 0)) {
printf("Timer::Init() called with bogus value \"%d\"! Not enabling timer.\n",
@@ -150,7 +149,7 @@ TimerImpl::Init(PRUint32 aDelay)
//printf("TimerImpl::Init called with delay %d only for %p\n", aDelay, this);
mDelay = aDelay;
// NS_ADDREF(this);
NS_ADDREF(this);
return NS_OK;
}

View File

@@ -1,43 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <Events.h>
#include "nscore.h"
#include "nsCaretProperties.h"
//-----------------------------------------------------------------------------
nsCaretProperties::nsCaretProperties()
: mCaretWidth(eDefaultCaretWidth)
, mBlinkRate(eDefaulBlinkRate)
{
// in your platform-specific class, get data from the OS in your constructor
// MacOS calls
mBlinkRate = ::GetCaretTime() * 1000 / 60;
}
//-----------------------------------------------------------------------------
nsCaretProperties* NewCaretProperties()
{
return new nsCaretProperties();
}

View File

@@ -22,12 +22,12 @@
#include "FullPath.h"
#include "FileCopy.h"
#include "MoreFilesExtras.h"
#include "nsEscape.h"
#include <Aliases.h>
#include <Folders.h>
#include <Errors.h>
#include <TextUtils.h>
#include <Processes.h>
const unsigned char* kAliasHavenFolderName = "\pnsAliasHaven";
@@ -44,23 +44,20 @@ namespace MacFileHelpers
void PLstrncpy(Str255 dst, const char* src, int inMaxLen);
void SwapSlashColon(char * s);
OSErr FSSpecFromUnixPath(
OSErr FSSpecFromFullUnixPath(
const char * unixPath,
FSSpec& ioSpec,
Boolean hexDecode,
FSSpec& outSpec,
Boolean resolveAlias,
Boolean allowPartial = false,
Boolean createDirs = false);
char* MacPathFromUnixPath(
const char* unixPath,
Boolean hexDecode);
char* MacPathFromUnixPath(const char* unixPath);
char* EncodeMacPath(
char* inPath, // NOT const - gets clobbered
Boolean prependSlash,
Boolean doEscape );
OSErr FSSpecFromPathname(
const char* inPathNamePtr,
FSSpec& ioSpec,
FSSpec& outSpec,
Boolean inCreateDirs);
char* PathNameFromFSSpec(
const FSSpec& inSpec,
@@ -77,7 +74,7 @@ namespace MacFileHelpers
// to support attaching of aliases in mail.
void EnsureAliasHaven();
void SetNoResolve(Boolean inResolve);
PRBool IsAliasSafe(const FSSpec& inSpec);
bool IsAliasSafe(const FSSpec& inSpec);
OSErr MakeAliasSafe(FSSpec& inOutSpec);
OSErr ResolveAliasFile(FSSpec& inOutSpec, Boolean& wasAliased);
@@ -134,8 +131,8 @@ char* MacFileHelpers::EncodeMacPath(
// Method: Swap ':' and '/', hex escape the result
//-----------------------------------
{
if (inPath == nsnull)
return nsnull;
if (inPath == NULL)
return NULL;
int pathSize = strlen(inPath);
// XP code sometimes chokes if there's a final slash in the unix path.
@@ -148,8 +145,8 @@ char* MacFileHelpers::EncodeMacPath(
pathSize--;
}
char * newPath = nsnull;
char * finalPath = nsnull;
char * newPath = NULL;
char * finalPath = NULL;
if (prependSlash)
{
@@ -191,10 +188,10 @@ OSErr MacFileHelpers::MakeAliasSafe(FSSpec& inOutSpec)
//----------------------------------------------------------------------------------------
{
EnsureAliasHaven();
nsFileSpec dstDirSpec(sAliasHavenVRefNum, sAliasHavenDirID, "\p");
nsNativeFileSpec dstDirSpec(sAliasHavenVRefNum, sAliasHavenDirID, "\p");
// Make sure its name is unique
nsFileSpec havenSpec(sAliasHavenVRefNum, sAliasHavenDirID, "\pG'day");
nsNativeFileSpec havenSpec(sAliasHavenVRefNum, sAliasHavenDirID, "\pG'day");
if (havenSpec.Valid())
havenSpec.MakeUnique(inOutSpec.name);
// Copy the file into the haven directory
@@ -214,7 +211,7 @@ OSErr MacFileHelpers::MakeAliasSafe(FSSpec& inOutSpec)
} // MacFileHelpers::MakeAliasSafe
//----------------------------------------------------------------------------------------
char* MacFileHelpers::MacPathFromUnixPath(const char* unixPath, Boolean hexDecode)
char* MacFileHelpers::MacPathFromUnixPath(const char* unixPath)
//----------------------------------------------------------------------------------------
{
// Relying on the fact that the unix path is always longer than the mac path:
@@ -224,13 +221,12 @@ char* MacFileHelpers::MacPathFromUnixPath(const char* unixPath, Boolean hexDecod
{
char* dst = result;
const char* src = unixPath;
if (*src == '/') // * full path
if (*src == '/') // ¥ full path
src++;
else if (strchr(src, '/')) // * partial path, and not just a leaf name
else if (strchr(src, '/')) // ¥ partial path, and not just a leaf name
*dst++ = ':';
strcpy(dst, src);
if (hexDecode)
nsUnescape(dst); // Hex Decode
nsUnescape(dst); // Hex Decode
MacFileHelpers::SwapSlashColon(dst);
}
return result;
@@ -239,7 +235,7 @@ char* MacFileHelpers::MacPathFromUnixPath(const char* unixPath, Boolean hexDecod
//----------------------------------------------------------------------------------------
OSErr MacFileHelpers::FSSpecFromPathname(
const char* inPathNamePtr,
FSSpec& ioSpec, // used as in-parameter for a relative path.
FSSpec& outSpec,
Boolean inCreateDirs)
// FSSpecFromPathname reverses PathNameFromFSSpec.
// It returns a FSSpec given a c string which is a mac pathname.
@@ -250,26 +246,20 @@ OSErr MacFileHelpers::FSSpecFromPathname(
// routine FSpLocationFromFullPath, which allocates memory, to handle longer pathnames.
size_t inLength = strlen(inPathNamePtr);
bool isRelative = (strchr(inPathNamePtr, ':') == 0 || *inPathNamePtr == ':');
if (inLength < 255)
{
Str255 ppath;
MacFileHelpers::PLstrcpy(ppath, inPathNamePtr);
if (isRelative)
err = ::FSMakeFSSpec(ioSpec.vRefNum, ioSpec.parID, ppath, &ioSpec);
else
err = ::FSMakeFSSpec(0, 0, ppath, &ioSpec);
err = ::FSMakeFSSpec(0, 0, ppath, &outSpec);
}
else if (!isRelative)
err = FSpLocationFromFullPath(inLength, inPathNamePtr, &ioSpec);
else
err = bdNamErr;
else
err = FSpLocationFromFullPath(inLength, inPathNamePtr, &outSpec);
if ((err == dirNFErr || err == bdNamErr) && inCreateDirs)
if (err == dirNFErr && inCreateDirs)
{
const char* path = inPathNamePtr;
ioSpec.vRefNum = 0;
ioSpec.parID = 0;
outSpec.vRefNum = 0;
outSpec.parID = 0;
do {
// Locate the colon that terminates the node.
// But if we've a partial path (starting with a colon), find the second one.
@@ -285,7 +275,7 @@ OSErr MacFileHelpers::FSSpecFromPathname(
// Use this string as a relative path using the directory created
// on the previous round (or directory 0,0 on the first round).
err = ::FSMakeFSSpec(ioSpec.vRefNum, ioSpec.parID, ppath, &ioSpec);
err = ::FSMakeFSSpec(outSpec.vRefNum, outSpec.parID, ppath, &outSpec);
// If this was the leaf node, then we are done.
if (!*nextColon)
@@ -294,7 +284,7 @@ OSErr MacFileHelpers::FSSpecFromPathname(
// If we got "file not found", then
// we need to create a directory.
if (err == fnfErr && *nextColon)
err = FSpDirCreate(&ioSpec, smCurrentScript, &ioSpec.parID);
err = FSpDirCreate(&outSpec, smCurrentScript, &outSpec.parID);
// For some reason, this usually returns fnfErr, even though it works.
if (err != noErr && err != fnfErr)
return err;
@@ -356,7 +346,7 @@ void MacFileHelpers::EnsureAliasHaven()
} // MacFileHelpers::EnsureAliasHaven
//----------------------------------------------------------------------------------------
PRBool MacFileHelpers::IsAliasSafe(const FSSpec& inSpec)
bool MacFileHelpers::IsAliasSafe(const FSSpec& inSpec)
// Returns true if the alias is in the alias haven directory, or if alias resolution
// has been turned off.
//----------------------------------------------------------------------------------------
@@ -377,10 +367,9 @@ OSErr MacFileHelpers::ResolveAliasFile(FSSpec& inOutSpec, Boolean& wasAliased)
} // MacFileHelpers::ResolveAliasFile
//-----------------------------------
OSErr MacFileHelpers::FSSpecFromUnixPath(
OSErr MacFileHelpers::FSSpecFromFullUnixPath(
const char * unixPath,
FSSpec& ioSpec,
Boolean hexDecode,
FSSpec& outSpec,
Boolean resolveAlias,
Boolean allowPartial,
Boolean createDirs)
@@ -390,9 +379,9 @@ OSErr MacFileHelpers::FSSpecFromUnixPath(
// then it is combined with inOutSpec's vRefNum and parID to form a new spec.
//-----------------------------------
{
if (unixPath == nsnull)
if (unixPath == NULL)
return badFidErr;
char* macPath = MacPathFromUnixPath(unixPath, hexDecode);
char* macPath = MacPathFromUnixPath(unixPath);
if (!macPath)
return memFullErr;
@@ -401,12 +390,12 @@ OSErr MacFileHelpers::FSSpecFromUnixPath(
{
NS_ASSERTION(*unixPath == '/' /*full path*/, "Not a full Unix path!");
}
err = FSSpecFromPathname(macPath, ioSpec, createDirs);
err = FSSpecFromPathname(macPath, outSpec, createDirs);
if (err == fnfErr)
err = noErr;
Boolean dummy;
if (err == noErr && resolveAlias) // Added
err = MacFileHelpers::ResolveAliasFile(ioSpec, dummy);
err = MacFileHelpers::ResolveAliasFile(outSpec, dummy);
delete [] macPath;
NS_ASSERTION(err==noErr||err==fnfErr||err==dirNFErr||err==nsvErr, "Not a path!");
return err;
@@ -424,7 +413,7 @@ char* MacFileHelpers::PathNameFromFSSpec( const FSSpec& inSpec, Boolean wantLeaf
OSErr err = noErr;
short fullPathLength = 0;
Handle fullPath = nsnull;
Handle fullPath = NULL;
FSSpec tempSpec = inSpec;
if ( tempSpec.parID == fsRtParID )
@@ -482,7 +471,7 @@ char* MacFileHelpers::PathNameFromFSSpec( const FSSpec& inSpec, Boolean wantLeaf
tempSpec.name[tempSpec.name[0]] = ':';
/* Add directory name to beginning of fullPath */
(void) Munger(fullPath, 0, nsnull, 0, &tempSpec.name[1], tempSpec.name[0]);
(void) Munger(fullPath, 0, NULL, 0, &tempSpec.name[1], tempSpec.name[0]);
err = MemError();
}
} while ( err == noErr && pb.dirInfo.ioDrDirID != fsRtDirID );
@@ -511,170 +500,107 @@ Clean:
} // MacFileHelpers::PathNameFromFSSpec
//========================================================================================
// Macintosh nsFileSpec implementation
// Macintosh nsNativeFileSpec implementation
//========================================================================================
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec()
nsNativeFileSpec::nsNativeFileSpec()
//----------------------------------------------------------------------------------------
: mError(NS_OK)
, mPath(nsnull)
: mError(noErr)
{
mSpec.name[0] = '\0';
}
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsFileSpec& inSpec)
nsNativeFileSpec::nsNativeFileSpec(const nsNativeFileSpec& inSpec)
//----------------------------------------------------------------------------------------
: mSpec(inSpec.mSpec)
, mPath(nsnull)
, mError(inSpec.Error())
{
}
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const char* inString, PRBool inCreateDirs)
nsNativeFileSpec::nsNativeFileSpec(const char* inString, bool inCreateDirs)
//----------------------------------------------------------------------------------------
: mPath(nsnull)
{
mSpec.vRefNum = 0;
mSpec.parID = 0;
// Convert unix (non-encoded) path to a spec.
mError = NS_FILE_RESULT(
MacFileHelpers::FSSpecFromUnixPath(
inString,
mSpec, false, false, true, inCreateDirs));
if (mError == NS_FILE_RESULT(fnfErr))
mError = NS_OK;
} // nsFileSpec::nsFileSpec
mError = MacFileHelpers::FSSpecFromFullUnixPath(
inString, mSpec, true, true, inCreateDirs);
// allow a partial path, create as necessary
if (mError == fnfErr)
mError = noErr;
} // nsNativeFileSpec::nsNativeFileSpec
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsString& inString, PRBool inCreateDirs)
nsNativeFileSpec::nsNativeFileSpec(
short vRefNum,
long parID,
ConstStr255Param name)
//----------------------------------------------------------------------------------------
: mPath(nsnull)
{
mSpec.vRefNum = 0;
mSpec.parID = 0;
// Convert unix (non-encoded) path to a spec.
mError = NS_FILE_RESULT(
MacFileHelpers::FSSpecFromUnixPath(
nsAutoCString(inString),
mSpec, false, false, true, inCreateDirs));
if (mError == NS_FILE_RESULT(fnfErr))
mError = NS_OK;
} // nsFileSpec::nsFileSpec
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(short vRefNum, long parID, ConstStr255Param name)
//----------------------------------------------------------------------------------------
: mPath(nsnull)
{
mError = NS_FILE_RESULT(::FSMakeFSSpec(vRefNum, parID, name, &mSpec));
if (mError == NS_FILE_RESULT(fnfErr))
mError = NS_OK;
mError = ::FSMakeFSSpec(vRefNum, parID, name, &mSpec);
if (mError == fnfErr)
mError = noErr;
}
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsFilePath& inPath)
nsNativeFileSpec::nsNativeFileSpec(const nsFilePath& inPath)
//----------------------------------------------------------------------------------------
: mPath(nsnull)
{
*this = inPath.GetFileSpec();
*this = inPath.GetNativeSpec();
}
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const char* inString)
nsBasicOutStream& operator << (nsBasicOutStream& s, const nsNativeFileSpec& spec)
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(mPath, nsnull);
mSpec.vRefNum = 0;
mSpec.parID = 0;
// Convert unix (non-encoded) path to a spec.
mError = NS_FILE_RESULT(
MacFileHelpers::FSSpecFromUnixPath(inString, mSpec, false, false, true));
if (mError == NS_FILE_RESULT(fnfErr))
mError = NS_OK;
} // nsFileSpec::operator =
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const nsFileSpec& inSpec)
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(mPath, nsnull);
mSpec = inSpec.mSpec;
mError = inSpec.Error();
} // nsFileSpec::operator =
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const nsFilePath& inPath)
//----------------------------------------------------------------------------------------
{
*this = inPath.GetFileSpec();
} // nsFileSpec::operator =
#if DEBUG
//----------------------------------------------------------------------------------------
nsOutputStream& operator << (nsOutputStream& s, const nsFileSpec& spec)
//----------------------------------------------------------------------------------------
{
#if 0
s << spec.mSpec.vRefNum << ", " << spec.mSpec.parID << ", \"";
s.write((const char*)&spec.mSpec.name[1], spec.mSpec.name[0]);
return s << "\"";
#else
return s << "\"" << spec.GetCString() << "\"";
#endif
} // nsOutputStream& operator << (nsOutputStream&, const nsFileSpec&)
#endif
} // nsOutputFileStream& operator << (nsOutputFileStream&, const nsNativeFileSpec&)
//----------------------------------------------------------------------------------------
PRBool nsFileSpec::Exists() const
void nsNativeFileSpec::operator = (const char* inString)
//----------------------------------------------------------------------------------------
{
mError = MacFileHelpers::FSSpecFromFullUnixPath(inString, mSpec, true);
} // nsNativeFileSpec::operator =
//----------------------------------------------------------------------------------------
void nsNativeFileSpec::operator = (const nsNativeFileSpec& inSpec)
//----------------------------------------------------------------------------------------
{
mSpec = inSpec.mSpec;
mError = inSpec.Error();
} // nsNativeFileSpec::operator =
//----------------------------------------------------------------------------------------
void nsNativeFileSpec::operator = (const nsFilePath& inPath)
//----------------------------------------------------------------------------------------
{
*this = inPath.GetNativeSpec();
} // nsNativeFileSpec::operator =
//----------------------------------------------------------------------------------------
bool nsNativeFileSpec::Exists() const
//----------------------------------------------------------------------------------------
{
FSSpec temp;
return ::FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, mSpec.name, &temp) == noErr;
} // nsFileSpec::Exists()
} // nsNativeFileSpec::operator =
//----------------------------------------------------------------------------------------
void nsFileSpec::GetModDate(TimeStamp& outStamp) const
//----------------------------------------------------------------------------------------
{
CInfoPBRec pb;
if (GetCatInfo(pb) == noErr)
outStamp = ((DirInfo*)&pb)->ioDrMdDat; // The mod date is in the same spot for files and dirs.
else
outStamp = 0;
} // nsFileSpec::GetModDate
//----------------------------------------------------------------------------------------
PRUint32 nsFileSpec::GetFileSize() const
//----------------------------------------------------------------------------------------
{
CInfoPBRec pb;
if (noErr == GetCatInfo(pb))
return (PRUint32)((HFileInfo*)&pb)->ioFlLgLen;
return 0;
} // nsFileSpec::GetFileSize
//----------------------------------------------------------------------------------------
void nsFileSpec::SetLeafName(const char* inLeafName)
void nsNativeFileSpec::SetLeafName(const char* inLeafName)
// In leaf name can actually be a partial path...
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(mPath, nsnull);
// what about long relative paths? Hmm? We don't have a routine for this anywhere.
// what about long relative paths? Hmm?
Str255 partialPath;
MacFileHelpers::PLstrcpy(partialPath, inLeafName);
mError = NS_FILE_RESULT(
::FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, partialPath, &mSpec));
if (mError == NS_FILE_RESULT(fnfErr))
mError = NS_OK;
} // nsFileSpec::SetLeafName
mError = FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, partialPath, &mSpec);
} // nsNativeFileSpec::SetLeafName
//----------------------------------------------------------------------------------------
char* nsFileSpec::GetLeafName() const
char* nsNativeFileSpec::GetLeafName() const
// Result needs to be delete[]ed.
//----------------------------------------------------------------------------------------
{
@@ -682,384 +608,151 @@ char* nsFileSpec::GetLeafName() const
memcpy(leaf, &mSpec.name[1], mSpec.name[0]);
leaf[mSpec.name[0]] = '\0';
return nsFileSpecHelpers::StringDup(leaf);
} // nsFileSpec::GetLeafName
} // nsNativeFileSpec::GetLeafName
//----------------------------------------------------------------------------------------
void nsFileSpec::MakeAliasSafe()
void nsNativeFileSpec::MakeAliasSafe()
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(mPath, nsnull);
mError = NS_FILE_RESULT(MacFileHelpers::MakeAliasSafe(mSpec));
} // nsFileSpec::MakeAliasSafe
mError = MacFileHelpers::MakeAliasSafe(mSpec);
} // nsNativeFileSpec::MakeAliasSafe
//----------------------------------------------------------------------------------------
void nsFileSpec::MakeUnique(ConstStr255Param inSuggestedLeafName)
void nsNativeFileSpec::MakeUnique(ConstStr255Param inSuggestedLeafName)
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(mPath, nsnull);
if (inSuggestedLeafName[0] > 0)
MacFileHelpers::PLstrcpy(mSpec.name, inSuggestedLeafName);
MakeUnique();
} // nsFileSpec::MakeUnique
} // nsNativeFileSpec::MakeUnique
//----------------------------------------------------------------------------------------
void nsFileSpec::ResolveAlias(PRBool& wasAliased)
void nsNativeFileSpec::ResolveAlias(bool& wasAliased)
//----------------------------------------------------------------------------------------
{
Boolean wasAliased2;
mError = NS_FILE_RESULT(MacFileHelpers::ResolveAliasFile(mSpec, wasAliased2));
mError = MacFileHelpers::ResolveAliasFile(mSpec, wasAliased2);
wasAliased = (wasAliased2 != false);
} // nsFileSpec::ResolveAlias
} // nsNativeFileSpec::ResolveAlias
//----------------------------------------------------------------------------------------
PRBool nsFileSpec::IsFile() const
bool nsNativeFileSpec::IsFile() const
//----------------------------------------------------------------------------------------
{
long dirID;
Boolean isDirectory;
return (noErr == FSpGetDirectoryID(&mSpec, &dirID, &isDirectory) && !isDirectory);
} // nsFileSpec::IsFile
} // nsNativeFileSpec::IsFile
//----------------------------------------------------------------------------------------
PRBool nsFileSpec::IsDirectory() const
bool nsNativeFileSpec::IsDirectory() const
//----------------------------------------------------------------------------------------
{
long dirID;
Boolean isDirectory;
return (noErr == FSpGetDirectoryID(&mSpec, &dirID, &isDirectory) && isDirectory);
} // nsFileSpec::IsDirectory
} // nsNativeFileSpec::IsDirectory
//----------------------------------------------------------------------------------------
void nsFileSpec::GetParent(nsFileSpec& outSpec) const
void nsNativeFileSpec::GetParent(nsNativeFileSpec& outSpec) const
//----------------------------------------------------------------------------------------
{
if (NS_SUCCEEDED(mError))
outSpec.mError
= NS_FILE_RESULT(::FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, nsnull, outSpec));
} // nsFileSpec::GetParent
if (mError == noErr)
outSpec.mError = FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, NULL, outSpec);
} // nsNativeFileSpec::GetParent
//----------------------------------------------------------------------------------------
void nsFileSpec::operator += (const char* inRelativePath)
void nsNativeFileSpec::operator += (const char* inRelativePath)
//----------------------------------------------------------------------------------------
{
long dirID;
Boolean isDirectory;
mError = NS_FILE_RESULT(::FSpGetDirectoryID(&mSpec, &dirID, &isDirectory));
if (NS_SUCCEEDED(mError) && isDirectory)
mError = FSpGetDirectoryID(&mSpec, &dirID, &isDirectory);
if (mError == noErr && isDirectory)
{
mSpec.parID = dirID;
// mSpec.vRefNum is already correct.
// Convert unix path (which is unencoded) to a spec
mError = NS_FILE_RESULT(
MacFileHelpers::FSSpecFromUnixPath(
inRelativePath, mSpec, false, false, true, true));
if (mError == NS_FILE_RESULT(fnfErr))
mError = NS_OK;
mError = FSMakeFSSpec(mSpec.vRefNum, dirID, "\pG'day", *this);
if (mError == noErr)
SetLeafName(inRelativePath);
}
} // nsFileSpec::operator +=
} // nsNativeFileSpec::operator +=
//----------------------------------------------------------------------------------------
void nsFileSpec::CreateDirectory(int /* unix mode */)
void nsNativeFileSpec::CreateDirectory(int /* unix mode */)
//----------------------------------------------------------------------------------------
{
long ignoredDirID;
mError = NS_FILE_RESULT(FSpDirCreate(&mSpec, smCurrentScript, &ignoredDirID));
} // nsFileSpec::CreateDirectory
FSpDirCreate(&mSpec, smCurrentScript, &ignoredDirID);
} // nsNativeFileSpec::CreateDirectory
//----------------------------------------------------------------------------------------
void nsFileSpec::Delete(PRBool inRecursive) const
void nsNativeFileSpec::Delete(bool inRecursive)
//----------------------------------------------------------------------------------------
{
nsresult& mutableError = const_cast<nsFileSpec*>(this)->mError;
if (inRecursive)
{
// MoreFilesExtras
mutableError = NS_FILE_RESULT(::DeleteDirectory(
mError = DeleteDirectory(
mSpec.vRefNum,
mSpec.parID,
const_cast<unsigned char*>(mSpec.name)));
const_cast<unsigned char*>(mSpec.name));
}
else
mutableError = NS_FILE_RESULT(FSpDelete(&mSpec));
} // nsFileSpec::Delete
mError = FSpDelete(&mSpec);
} // nsNativeFileSpec::Delete
//----------------------------------------------------------------------------------------
nsresult nsFileSpec::Rename(const char* inNewName)
//----------------------------------------------------------------------------------------
{
if (strchr(inNewName, '/'))
return -1; // no relative paths here!
Str255 pName;
MacFileHelpers::PLstrcpy(pName, inNewName);
if (FSpRename(&mSpec, pName) != noErr)
return -1;
SetLeafName(inNewName);
return 0;
} // nsFileSpec::Rename
//----------------------------------------------------------------------------------------
nsresult nsFileSpec::Copy(const nsFileSpec& newParentDir) const
//----------------------------------------------------------------------------------------
{
// We can only copy into a directory, and (for now) can not copy entire directories
if (!newParentDir.IsDirectory() || (IsDirectory() ) )
return NS_FILE_FAILURE;
nsresult result = NS_FILE_RESULT(::FSpFileCopy( &mSpec,
&newParentDir.mSpec,
const_cast<StringPtr>(GetLeafPName()),
nsnull,
0,
true));
return result;
} // nsFileSpec::Copy
//----------------------------------------------------------------------------------------
nsresult nsFileSpec::Move(const nsFileSpec& newParentDir) const
//----------------------------------------------------------------------------------------
{
// We can only move into a directory
if (!newParentDir.IsDirectory())
return NS_FILE_FAILURE;
nsresult result = NS_FILE_RESULT(::FSpMoveRenameCompat(&mSpec,
&newParentDir.mSpec,
const_cast<StringPtr>(GetLeafPName())));
return result;
} // nsFileSpec::Move
//----------------------------------------------------------------------------------------
nsresult nsFileSpec::Execute(const char* /*args - how can this be cross-platform? problem! */ ) const
//----------------------------------------------------------------------------------------
{
if (IsDirectory())
return NS_FILE_FAILURE;
LaunchParamBlockRec launchThis;
launchThis.launchAppSpec = const_cast<FSSpec*>(&mSpec);
launchThis.launchAppParameters = nsnull; // args;
/* launch the thing */
launchThis.launchBlockID = extendedBlock;
launchThis.launchEPBLength = extendedBlockLen;
launchThis.launchFileFlags = nsnull;
launchThis.launchControlFlags = launchContinue + launchNoFileFlags + launchUseMinimum;
launchThis.launchControlFlags += launchDontSwitch;
nsresult result = NS_FILE_RESULT(::LaunchApplication(&launchThis));
return result;
} // nsFileSpec::Execute
//----------------------------------------------------------------------------------------
OSErr nsFileSpec::GetCatInfo(CInfoPBRec& outInfo) const
//----------------------------------------------------------------------------------------
{
DirInfo *dipb=(DirInfo *)&outInfo;
dipb->ioCompletion = nsnull;
dipb->ioFDirIndex = 0; // use dirID and name
dipb->ioVRefNum = mSpec.vRefNum;
dipb->ioDrDirID = mSpec.parID;
dipb->ioNamePtr = const_cast<nsFileSpec*>(this)->mSpec.name;
return PBGetCatInfoSync(&outInfo);
} // nsFileSpec::GetCatInfo()
//----------------------------------------------------------------------------------------
PRUint32 nsFileSpec::GetDiskSpaceAvailable() const
//----------------------------------------------------------------------------------------
{
HVolumeParam pb;
pb.ioCompletion = NULL;
pb.ioVolIndex = 0;
pb.ioNamePtr = NULL;
pb.ioVRefNum = mSpec.vRefNum;
OSErr err = PBHGetVInfoSync( (HParmBlkPtr)&pb );
if ( err == noErr )
return pb.ioVFrBlk * pb.ioVAlBlkSiz;
return ULONG_MAX;
} // nsFileSpec::GetDiskSpace()
//----------------------------------------------------------------------------------------
const char* nsFileSpec::GetCString() const
// This is the only conversion to const char* that is provided, and it allows the
// path to be "passed" to NSPR file routines. This practice is VERY EVIL and should only
// be used to support legacy code. Using it guarantees bugs on Macintosh. The string is
// cached and freed by the nsFileSpec destructor, so do not delete (or free) it.
//----------------------------------------------------------------------------------------
{
if (!mPath)
{
const_cast<nsFileSpec*>(this)->mPath
= MacFileHelpers::PathNameFromFSSpec(mSpec, true);
if (!mPath)
const_cast<nsFileSpec*>(this)->mError = NS_ERROR_OUT_OF_MEMORY;
}
return mPath;
}
//========================================================================================
// Macintosh nsFilePath implementation
//========================================================================================
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const char* inString, PRBool inCreateDirs)
nsFilePath::nsFilePath(const char* inString, bool inCreateDirs)
//----------------------------------------------------------------------------------------
: mPath(nsnull)
, mFileSpec(inString, inCreateDirs)
, mNativeFileSpec(inString, inCreateDirs)
{
// Make canonical and absolute.
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, true );
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
char * path = MacFileHelpers::PathNameFromFSSpec( mNativeFileSpec, TRUE );
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
}
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const nsNativeFileSpec& inSpec)
//----------------------------------------------------------------------------------------
: mNativeFileSpec(inSpec)
{
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, TRUE );
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
}
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
: mPath(nsnull)
, mFileSpec(nsAutoCString(inString), inCreateDirs)
{
// Make canonical and absolute.
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, true );
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
}
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const nsFileSpec& inSpec)
//----------------------------------------------------------------------------------------
: mPath(nsnull)
{
*this = inSpec;
}
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const nsFileURL& inOther)
//----------------------------------------------------------------------------------------
: mPath(nsnull)
{
*this = inOther.GetFileSpec();
}
//----------------------------------------------------------------------------------------
void nsFilePath::operator = (const nsFileSpec& inSpec)
void nsFilePath::operator = (const nsNativeFileSpec& inSpec)
//----------------------------------------------------------------------------------------
{
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, true );
delete [] mPath;
mPath = MacFileHelpers::EncodeMacPath(path, true, false);
mFileSpec = inSpec;
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, TRUE );
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
mNativeFileSpec = inSpec;
} // nsFilePath::operator =
//----------------------------------------------------------------------------------------
void nsFilePath::operator = (const nsFileURL& inOther)
//----------------------------------------------------------------------------------------
{
*this = inOther.GetFileSpec();
}
//========================================================================================
// nsFileURL implementation
//========================================================================================
//----------------------------------------------------------------------------------------
nsFileURL::nsFileURL(const char* inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
: mURL(nsFileSpecHelpers::StringDup(inString))
{
NS_ASSERTION(strstr(mURL, kFileURLPrefix) == mURL, "Not a URL!");
mFileSpec.mError = NS_FILE_RESULT(MacFileHelpers::FSSpecFromUnixPath(
mURL + kFileURLPrefixLength,
mFileSpec.mSpec,
true, // need to decode
false, // don't resolve alias
false, // must be a full path
inCreateDirs));
if (mFileSpec.mError == NS_FILE_RESULT(fnfErr))
mFileSpec.mError = NS_OK;
} // nsFileURL::nsFileURL
//----------------------------------------------------------------------------------------
nsFileURL::nsFileURL(const nsString& inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
: mURL(nsFileSpecHelpers::StringDup(nsAutoCString(inString)))
{
NS_ASSERTION(strstr(mURL, kFileURLPrefix) == mURL, "Not a URL!");
mFileSpec.mError = NS_FILE_RESULT(MacFileHelpers::FSSpecFromUnixPath(
mURL + kFileURLPrefixLength,
mFileSpec.mSpec,
true, // need to decode
false, // don't resolve alias
false, // must be a full path
inCreateDirs));
if (mFileSpec.mError == NS_FILE_RESULT(fnfErr))
mFileSpec.mError = NS_OK;
} // nsFileURL::nsFileURL
//----------------------------------------------------------------------------------------
nsFileURL::nsFileURL(const nsFilePath& inOther)
nsFileURL::nsFileURL(const char* inString, bool inCreateDirs)
//----------------------------------------------------------------------------------------
: mURL(nsnull)
, mNativeFileSpec(inString + kFileURLPrefixLength, inCreateDirs)
{
*this = inOther.GetFileSpec();
} // nsFileURL::nsFileURL
//----------------------------------------------------------------------------------------
nsFileURL::nsFileURL(const nsFileSpec& inOther)
: mURL(nsnull)
//----------------------------------------------------------------------------------------
{
*this = inOther;
} // nsFileURL::nsFileURL
//----------------------------------------------------------------------------------------
void nsFileURL::operator = (const nsFilePath& inOther)
//----------------------------------------------------------------------------------------
{
*this = inOther.GetFileSpec();
} // nsFileURL::operator =
//----------------------------------------------------------------------------------------
void nsFileURL::operator = (const nsFileSpec& inOther)
//----------------------------------------------------------------------------------------
{
mFileSpec = inOther;
delete [] mURL;
char* path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, true );
char* encodedPath = MacFileHelpers::EncodeMacPath(path, true, true);
char* encodedURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, encodedPath);
delete [] encodedPath;
if (encodedURL[strlen(encodedURL) - 1] != '/' && inOther.IsDirectory())
{
mURL = nsFileSpecHelpers::AllocCat(encodedURL, "/");
delete [] encodedURL;
}
else
mURL = encodedURL;
} // nsFileURL::operator =
//----------------------------------------------------------------------------------------
void nsFileURL::operator = (const char* inString)
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(mURL, inString);
NS_ASSERTION(strstr(inString, kFileURLPrefix) == inString, "Not a URL!");
mFileSpec.mError = NS_FILE_RESULT(MacFileHelpers::FSSpecFromUnixPath(
inString + kFileURLPrefixLength,
mFileSpec.mSpec,
true, // need to decode
false, // don't resolve alias
false, // must be a full path
false)); // don't create dirs.
if (mFileSpec.mError == NS_FILE_RESULT(fnfErr))
mFileSpec.mError = NS_OK;
} // nsFileURL::operator =
// Make canonical and absolute.
char* path = MacFileHelpers::PathNameFromFSSpec( mNativeFileSpec, TRUE );
char* escapedPath = MacFileHelpers::EncodeMacPath(path, true, true);
mURL = nsFileSpecHelpers::StringDup(kFileURLPrefix, kFileURLPrefixLength + strlen(escapedPath));
strcat(mURL, escapedPath);
delete [] escapedPath;
} // nsFileURL::nsFileURL
//========================================================================================
// nsDirectoryIterator
@@ -1067,7 +760,7 @@ void nsFileURL::operator = (const char* inString)
//----------------------------------------------------------------------------------------
nsDirectoryIterator::nsDirectoryIterator(
const nsFileSpec& inDirectory
const nsNativeFileSpec& inDirectory
, int inIterateDirection)
//----------------------------------------------------------------------------------------
: mCurrent(inDirectory)
@@ -1075,15 +768,24 @@ nsDirectoryIterator::nsDirectoryIterator(
, mIndex(-1)
{
CInfoPBRec pb;
OSErr err = inDirectory.GetCatInfo(pb);
// test that we have got a directory back, not a file
DirInfo* dipb = (DirInfo*)&pb;
if (err != noErr || !( dipb->ioFlAttrib & 0x0010))
// Sorry about this, there seems to be a bug in CWPro 4:
const FSSpec& inSpec = inDirectory.nsNativeFileSpec::operator const FSSpec&();
Str255 outName;
MacFileHelpers::PLstrcpy(outName, inSpec.name);
pb.hFileInfo.ioNamePtr = outName;
pb.hFileInfo.ioVRefNum = inSpec.vRefNum;
pb.hFileInfo.ioDirID = inSpec.parID;
pb.hFileInfo.ioFDirIndex = 0; // use ioNamePtr and ioDirID
OSErr err = PBGetCatInfoSync( &pb );
// test that we have got a directory back, not a file
if ( (err != noErr ) || !( dipb->ioFlAttrib & 0x0010 ) )
return;
// Sorry about this, there seems to be a bug in CWPro 4:
FSSpec& currentSpec = mCurrent.nsFileSpec::operator FSSpec&();
currentSpec.vRefNum = currentSpec.vRefNum;
FSSpec& currentSpec = mCurrent.nsNativeFileSpec::operator FSSpec&();
currentSpec.vRefNum = inSpec.vRefNum;
currentSpec.parID = dipb->ioDrDirID;
mMaxIndex = pb.dirInfo.ioDrNmFls;
if (inIterateDirection > 0)
@@ -1105,10 +807,10 @@ OSErr nsDirectoryIterator::SetToIndex()
CInfoPBRec cipb;
DirInfo *dipb=(DirInfo *)&cipb;
Str255 objectName;
dipb->ioCompletion = nsnull;
dipb->ioCompletion = NULL;
dipb->ioFDirIndex = mIndex;
// Sorry about this, there seems to be a bug in CWPro 4:
FSSpec& currentSpec = mCurrent.nsFileSpec::operator FSSpec&();
FSSpec& currentSpec = mCurrent.nsNativeFileSpec::operator FSSpec&();
dipb->ioVRefNum = currentSpec.vRefNum; /* Might need to use vRefNum, not sure*/
dipb->ioDrDirID = currentSpec.parID;
dipb->ioNamePtr = objectName;
@@ -1147,4 +849,3 @@ nsDirectoryIterator& nsDirectoryIterator::operator ++ ()
}
return *this;
} // nsDirectoryIterator::operator ++

View File

@@ -39,16 +39,12 @@ class TimerImpl : public nsITimer
// TimerImpl implements nsITimer API
//========================================================================================
{
friend class TimerPeriodical;
private:
nsTimerCallbackFunc mCallbackFunc;
nsITimerCallback * mCallbackObject;
void * mClosure;
PRUint32 mDelay;
PRUint32 mFireTime; // Timer should fire when TickCount >= this number
TimerImpl * mPrev;
TimerImpl * mNext;
public:
@@ -107,10 +103,10 @@ class TimerPeriodical : public Repeater
// TimerPeriodical is a singleton Repeater subclass that fires
// off TimerImpl. The firing is done on idle.
//========================================================================================
{
{
static TimerPeriodical * gPeriodical;
TimerImpl* mTimers;
list<TimerImpl*> mTimers;
public:
// Returns the singleton instance
@@ -133,7 +129,8 @@ class TimerPeriodical : public Repeater
// TimerImpl implementation
//========================================================================================
NS_IMPL_ISUPPORTS(TimerImpl, nsITimer::GetIID())
static NS_DEFINE_IID(kITimerIID, NS_ITIMER_IID);
NS_IMPL_ISUPPORTS(TimerImpl, kITimerIID)
//----------------------------------------------------------------------------------------
TimerImpl::TimerImpl()
@@ -143,8 +140,6 @@ TimerImpl::TimerImpl()
, mClosure(nsnull)
, mDelay(0)
, mFireTime(0)
, mPrev(nsnull)
, mNext(nsnull)
#if DEBUG
, mSignature(eGoodTimerSignature)
#endif
@@ -190,6 +185,7 @@ nsresult TimerImpl::Init(nsITimerCallback *aCallback,
void TimerImpl::Cancel()
//----------------------------------------------------------------------------------------
{
TimerPeriodical::GetPeriodical()->RemoveTimer(this);
}
@@ -255,70 +251,26 @@ TimerPeriodical * TimerPeriodical::GetPeriodical()
TimerPeriodical::TimerPeriodical()
{
mTimers = nsnull;
}
TimerPeriodical::~TimerPeriodical()
{
PR_ASSERT(mTimers == 0);
PR_ASSERT(mTimers.size() == 0);
}
nsresult TimerPeriodical::AddTimer( TimerImpl * aTimer)
{
// make sure it's not already there
RemoveTimer(aTimer);
// keep list sorted by fire time
if (mTimers)
{
if (aTimer->GetFireTime() < mTimers->GetFireTime())
{
mTimers->mPrev = aTimer;
aTimer->mNext = mTimers;
mTimers = aTimer;
}
else
{
TimerImpl *t = mTimers;
TimerImpl *prevt;
// we know we will enter the while loop at least the first
// time, and thus prevt will be initialized
while (t && (t->GetFireTime() <= aTimer->GetFireTime()))
{
prevt = t;
t = t->mNext;
}
aTimer->mPrev = prevt;
aTimer->mNext = prevt->mNext;
prevt->mNext = aTimer;
if (aTimer->mNext) aTimer->mNext->mPrev = aTimer;
}
}
else mTimers = aTimer;
mTimers.remove(aTimer);
mTimers.push_back(aTimer);
StartRepeating();
return NS_OK;
}
nsresult TimerPeriodical::RemoveTimer( TimerImpl * aTimer)
{
TimerImpl* t = mTimers;
TimerImpl* next_t = nsnull;
if (t) next_t = t->mNext;
while (t)
{
if (t == aTimer)
{
if (mTimers == t) mTimers = t->mNext;
if (t->mPrev) t->mPrev->mNext = t->mNext;
if (t->mNext) t->mNext->mPrev = t->mPrev;
t->mNext = nsnull;
t->mPrev = nsnull;
}
t = next_t;
if (t) next_t = t->mNext;
}
if ( mTimers == nsnull )
mTimers.remove(aTimer);
if ( mTimers.size() == 0 )
StopRepeating();
return NS_OK;
}
@@ -328,23 +280,33 @@ nsresult TimerPeriodical::RemoveTimer( TimerImpl * aTimer)
// fires off the appropriate ones
void TimerPeriodical::RepeatAction( const EventRecord &inMacEvent)
{
PRBool done = false;
while (!done)
list<TimerImpl*>::iterator iter = mTimers.begin();
list<TimerImpl*> fireList;
while (iter != mTimers.end())
{
TimerImpl* t = mTimers;
while (t)
{
NS_ASSERTION(t->IsGoodTimer(), "Bad timer!");
TimerImpl* timer = *iter;
if (t->GetFireTime() <= inMacEvent.when)
{
RemoveTimer(t);
t->Fire();
break;
}
t = t->mNext;
NS_ASSERTION(timer->IsGoodTimer(), "Bad timer!");
if (timer->GetFireTime() <= inMacEvent.when)
{
mTimers.erase(iter++);
NS_ADDREF(timer);
fireList.push_back(timer);
}
done = true;
else
{
iter++;
}
}
if ( mTimers.size() == 0 )
StopRepeating();
for (iter=fireList.begin(); iter!=fireList.end(); iter++)
{
(*iter)->Fire();
NS_RELEASE(*iter);
}
}
@@ -360,5 +322,5 @@ NS_BASE nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
return NS_ERROR_OUT_OF_MEMORY;
}
return timer->QueryInterface(nsITimer::GetIID(), (void **) aInstancePtrResult);
return timer->QueryInterface(kITimerIID, (void **) aInstancePtrResult);
}

View File

@@ -40,10 +40,6 @@ CPPSRCS = \
nsVoidArray.cpp \
nsFileSpec.cpp \
nsFileStream.cpp \
nsStringStream.cpp \
nsEscape.cpp \
nsIFileStream.cpp \
nsSpecialSystemDirectory.cpp \
$(NULL)
CPP_OBJS = \
@@ -63,10 +59,6 @@ CPP_OBJS = \
.\$(OBJDIR)\nsVoidArray.obj \
.\$(OBJDIR)\nsFileSpec.obj \
.\$(OBJDIR)\nsFileStream.obj \
.\$(OBJDIR)\nsEscape.obj \
.\$(OBJDIR)\nsIFileStream.obj \
.\$(OBJDIR)\nsIStringStream.obj \
.\$(OBJDIR)\nsSpecialSystemDirectory.obj \
$(NULL)
EXPORTS=nscore.h nsIArena.h nsIAtom.h nsIByteBuffer.h \
@@ -79,16 +71,16 @@ EXPORTS=nscore.h nsIArena.h nsIAtom.h nsIByteBuffer.h \
MODULE=raptor
REQUIRES=xpcom netlib raptor uconv
REQUIRES=xpcom netlib raptor
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\netlib \
-I$(PUBLIC)\raptor -I$(PUBLIC)\uconv -I$(PUBLIC)\unicharutil
-I$(PUBLIC)\raptor
MAKE_OBJ_TYPE = DLL
DLLNAME = raptorbase
DLL=.\$(OBJDIR)\$(DLLNAME).dll
OBJS = $(OBJS) .\$(OBJDIR)\nsTimer.obj .\$(OBJDIR)\nsCaretProperties.obj
OBJS = $(OBJS) .\$(OBJDIR)\nsTimer.obj
LCFLAGS = \
$(LCFLAGS) \
@@ -98,7 +90,7 @@ LCFLAGS = \
# These are the libraries we need to link with to create the dll
LLIBS= \
$(DIST)\lib\xpcom32.lib \
$(DIST)\lib\plc3.lib \
$(DIST)\lib\libplc21.lib \
$(LIBNSPR)
!if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE)
LLIBS=$(LLIBS) $(GLOWDIR)\glowcode.lib

View File

@@ -30,10 +30,7 @@ REQUIRES = xpcom raptor
DEFINES += -D_IMPL_NS_WIDGET
CPPSRCS = \
nsTimer.cpp \
nsCaretProperties.cpp \
$(NULL)
CPPSRCS = nsTimer.cpp
include $(topsrcdir)/config/rules.mk

View File

@@ -1,39 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nscore.h"
#include "nsCaretProperties.h"
//-----------------------------------------------------------------------------
nsCaretProperties::nsCaretProperties()
: mCaretWidth(eDefaultCaretWidth)
, mBlinkRate(eDefaulBlinkRate)
{
// in your platform-specific class, get data from the OS in your constructor
}
//-----------------------------------------------------------------------------
nsCaretProperties* NewCaretProperties()
{
return new nsCaretProperties();
}

View File

@@ -36,10 +36,6 @@ public:
void* operator new(size_t size, const PRUnichar* us, PRInt32 uslen);
void operator delete(void* ptr) {
::operator delete(ptr);
}
virtual void ToString(nsString& aBuf) const;
virtual const PRUnichar* GetUnicode() const;
@@ -79,7 +75,7 @@ NS_IMPL_ISUPPORTS(AtomImpl, kIAtomIID);
void* AtomImpl::operator new(size_t size, const PRUnichar* us, PRInt32 uslen)
{
size = size + uslen * sizeof(PRUnichar);
AtomImpl* ii = (AtomImpl*) ::operator new(size);
AtomImpl* ii = (AtomImpl*) new char[size];
nsCRT::memcpy(ii->mString, us, uslen * sizeof(PRUnichar));
ii->mString[uslen] = 0;
return ii;
@@ -134,7 +130,7 @@ NS_BASE nsIAtom* NS_NewAtom(const PRUnichar* us)
(PLHashComparator) nsnull,
nsnull, nsnull);
}
PRUint32 uslen;
PRInt32 uslen;
PRUint32 hashCode = nsCRT::HashValue(us, &uslen);
PLHashEntry** hep = PL_HashTableRawLookup(gAtomHashTable, hashCode, us);
PLHashEntry* he = *hep;

View File

@@ -20,63 +20,41 @@
#include "nscore.h"
#include "nsIProperties.h"
#include "nsProperties.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsRepository.h"
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
PRInt32 gLockCount = 0;
extern "C" PRInt32 gLockCount = 0;
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
extern "C" NS_EXPORT nsresult
NSRegisterSelf(nsISupports* aServMgr, const char* path)
NSRegisterSelf(const char* path)
{
nsresult rv;
nsresult ret;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
ret = nsRepository::RegisterFactory(kPropertiesCID, path, PR_TRUE,
PR_TRUE);
if (NS_FAILED(ret)) {
return ret;
}
nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) return rv;
rv = compMgr->RegisterComponent(kPropertiesCID, NULL, NULL,
path, PR_TRUE, PR_TRUE);
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
return ret;
}
extern "C" NS_EXPORT nsresult
NSUnregisterSelf(nsISupports* aServMgr, const char* path)
NSUnregisterSelf(const char* path)
{
nsresult rv;
nsresult ret;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
ret = nsRepository::UnregisterFactory(kPropertiesCID, path);
if (NS_FAILED(ret)) {
return ret;
}
nsIComponentManager* compMgr;
rv = servMgr->GetService(kComponentManagerCID,
nsIComponentManager::GetIID(),
(nsISupports**)&compMgr);
if (NS_FAILED(rv)) return rv;
rv = compMgr->UnregisterFactory(kPropertiesCID, path);
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
return rv;
return ret;
}
extern "C" NS_EXPORT nsresult
NSGetFactory(nsISupports* aServMgr,
const nsCID& aClass,
const char *aClassName,
const char *aProgID,
nsIFactory** aFactory)
NSGetFactory(const nsCID& aClass, nsISupports* aServMgr, nsIFactory** aFactory)
{
nsresult res;
@@ -100,9 +78,3 @@ NSGetFactory(nsISupports* aServMgr,
return NS_NOINTERFACE;
}
extern "C" NS_EXPORT PRBool
NSCanUnload(nsISupports* serviceMgr)
{
return PR_FALSE; // XXX can we unload this?
}

View File

@@ -21,6 +21,6 @@
#include "prtypes.h"
extern PRInt32 gLockCount;
extern "C" PRInt32 gLockCount;
#endif /* nsBaseDLL_h___ */

View File

@@ -56,7 +56,7 @@ NS_IMPL_ISUPPORTS(ByteBufferImpl,kByteBufferIID)
ByteBufferImpl::~ByteBufferImpl()
{
if (nsnull != mBuffer) {
delete[] mBuffer;
delete mBuffer;
mBuffer = nsnull;
}
mLength = 0;
@@ -87,7 +87,7 @@ PRBool ByteBufferImpl::Grow(PRUint32 aNewSize)
if (0 != mLength) {
nsCRT::memcpy(newbuf, mBuffer, mLength);
}
delete[] mBuffer;
delete mBuffer;
mBuffer = newbuf;
return PR_TRUE;
}
@@ -112,8 +112,9 @@ PRInt32 ByteBufferImpl::Fill(nsresult* aErrorCode, nsIInputStream* aStream,
// Read in some new data
mLength = aKeep;
PRUint32 amount = mSpace - aKeep;
PRUint32 nb;
*aErrorCode = aStream->Read(mBuffer + aKeep, mSpace - aKeep, &nb);
*aErrorCode = aStream->Read(mBuffer, aKeep, amount, &nb);
if (NS_SUCCEEDED(*aErrorCode)) {
mLength += nb;
}

View File

@@ -33,10 +33,6 @@
#include "nsCRT.h"
#include "nsUnicharUtilCIID.h"
#include "nsIServiceManager.h"
#include "nsICaseConversion.h"
// XXX Bug: These tables don't lowercase the upper 128 characters properly
@@ -113,77 +109,21 @@ static const PRUnichar kIsoLatin1ToUCS2[256] = {
//----------------------------------------------------------------------
#define TOLOWER(_ucs2) \
(((_ucs2) < 128) ? PRUnichar(kUpper2Lower[_ucs2]) : _ToLower(_ucs2))
(((_ucs2) < 256) ? PRUnichar(kUpper2Lower[_ucs2]) : _ToLower(_ucs2))
#define TOUPPER(_ucs2) \
(((_ucs2) < 128) ? PRUnichar(kLower2Upper[_ucs2]) : _ToUpper(_ucs2))
class HandleCaseConversionShutdown : public nsIShutdownListener {
public :
NS_IMETHOD OnShutdown(const nsCID& cid, nsISupports* service);
HandleCaseConversionShutdown(void) { NS_INIT_REFCNT(); }
virtual ~HandleCaseConversionShutdown(void) {}
NS_DECL_ISUPPORTS
};
static NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID);
static NS_DEFINE_IID(kICaseConversionIID, NS_ICASECONVERSION_IID);
static nsICaseConversion * gCaseConv = NULL;
static NS_DEFINE_IID(kIShutdownListenerIID, NS_ISHUTDOWNLISTENER_IID);
NS_IMPL_ISUPPORTS(HandleCaseConversionShutdown, kIShutdownListenerIID);
nsresult
HandleCaseConversionShutdown::OnShutdown(const nsCID& cid, nsISupports* service)
{
if (cid.Equals(kUnicharUtilCID)) {
NS_ASSERTION(service == gCaseConv, "wrong service!");
nsrefcnt cnt = gCaseConv->Release();
gCaseConv = NULL;
}
return NS_OK;
}
static HandleCaseConversionShutdown* gListener = NULL;
static void StartUpCaseConversion()
{
nsresult err;
if ( NULL == gListener )
{
gListener = new HandleCaseConversionShutdown();
gListener->AddRef();
}
err = nsServiceManager::GetService(kUnicharUtilCID, kICaseConversionIID,
(nsISupports**) &gCaseConv, gListener);
}
static void CheckCaseConversion()
{
if(NULL == gCaseConv )
StartUpCaseConversion();
NS_ASSERTION( gCaseConv != NULL , "cannot obtain UnicharUtil");
}
(((_ucs2) < 256) ? PRUnichar(kLower2Upper[_ucs2]) : _ToUpper(_ucs2))
static PRUnichar _ToLower(PRUnichar aChar)
{
PRUnichar oLower;
CheckCaseConversion();
nsresult err = gCaseConv->ToLower(aChar, &oLower);
NS_ASSERTION( NS_SUCCEEDED(err), "failed to communicate to UnicharUtil");
return ( NS_SUCCEEDED(err) ) ? oLower : aChar ;
// XXX need i18n code here
return aChar;
}
static PRUnichar _ToUpper(PRUnichar aChar)
{
nsresult err;
PRUnichar oUpper;
CheckCaseConversion();
err = gCaseConv->ToUpper(aChar, &oUpper);
NS_ASSERTION( NS_SUCCEEDED(err), "failed to communicate to UnicharUtil");
return ( NS_SUCCEEDED(err) ) ? oUpper : aChar ;
// XXX need i18n code here
return aChar;
}
//----------------------------------------------------------------------
@@ -198,63 +138,9 @@ PRUnichar nsCRT::ToLower(PRUnichar aChar)
return TOLOWER(aChar);
}
PRBool nsCRT::IsUpper(PRUnichar aChar)
PRInt32 nsCRT::strlen(const PRUnichar* s)
{
return aChar != nsCRT::ToLower(aChar);
}
PRBool nsCRT::IsLower(PRUnichar aChar)
{
return aChar != nsCRT::ToUpper(aChar);
}
////////////////////////////////////////////////////////////////////////////////
// My lovely strtok routine
#define IS_DELIM(m, c) ((m)[(c) >> 3] & (1 << ((c) & 7)))
#define SET_DELIM(m, c) ((m)[(c) >> 3] |= (1 << ((c) & 7)))
#define DELIM_TABLE_SIZE 32
char* nsCRT::strtok(char* str, const char* delims, char* *newStr)
{
NS_ASSERTION(str, "Unlike regular strtok, the first argument cannot be null.");
char delimTable[DELIM_TABLE_SIZE];
PRUint32 i;
char* result;
for (i = 0; i < DELIM_TABLE_SIZE; i++)
delimTable[i] = '\0';
for (i = 0; i < DELIM_TABLE_SIZE && delims[i]; i++) {
SET_DELIM(delimTable, delims[i]);
}
NS_ASSERTION(delims[i] == '\0', "too many delimiters");
// skip to beginning
while (*str && IS_DELIM(delimTable, *str)) {
str++;
}
result = str;
// fix up the end of the token
while (*str) {
if (IS_DELIM(delimTable, *str)) {
*str++ = '\0';
break;
}
str++;
}
*newStr = str;
return str == result ? NULL : result;
}
////////////////////////////////////////////////////////////////////////////////
PRUint32 nsCRT::strlen(const PRUnichar* s)
{
PRUint32 len = 0;
PRInt32 len = 0;
if(s) {
while (*s++ != 0) {
len++;
@@ -294,11 +180,11 @@ PRInt32 nsCRT::strcmp(const PRUnichar* s1, const PRUnichar* s2)
* @param s1 and s2 both point to unichar strings
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
*/
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRUint32 n)
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
{
if(s1 && s2) {
if(n != 0) {
do {
if(0<n) {
while (--n >= 0) {
PRUnichar c1 = *s1++;
PRUnichar c2 = *s2++;
if (c1 != c2) {
@@ -306,7 +192,7 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRUint32 n)
return 1;
}
if ((0==c1) || (0==c2)) break;
} while (--n != 0);
}
}
}
return 0;
@@ -348,7 +234,7 @@ PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const PRUnichar* s2)
* @param s1 and s2 both point to unichar strings
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
*/
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRUint32 n)
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const PRUnichar* s2, PRInt32 n)
{
if(s1 && s2) {
if(0<n){
@@ -404,11 +290,11 @@ PRInt32 nsCRT::strcmp(const PRUnichar* s1, const char* s2)
* @param s2 points to cstring
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
*/
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const char* s2, PRUint32 n)
PRInt32 nsCRT::strncmp(const PRUnichar* s1, const char* s2, PRInt32 n)
{
if(s1 && s2) {
if(n != 0){
do {
if(0<n){
while (--n >= 0) {
PRUnichar c1 = *s1++;
PRUnichar c2 = kIsoLatin1ToUCS2[*(const unsigned char*)s2++];
if (c1 != c2) {
@@ -416,7 +302,7 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const char* s2, PRUint32 n)
return 1;
}
if ((0==c1) || (0==c2)) break;
} while (--n != 0);
}
}
}
return 0;
@@ -458,11 +344,11 @@ PRInt32 nsCRT::strcasecmp(const PRUnichar* s1, const char* s2)
* @param s2 points to cstring
* @return 0 if they match, -1 if s1<s2; 1 if s1>s2
*/
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRUint32 n)
PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRInt32 n)
{
if(s1 && s2){
if(n != 0){
do {
if(0<n){
while (--n >= 0) {
PRUnichar c1 = *s1++;
PRUnichar c2 = kIsoLatin1ToUCS2[*(const unsigned char*)s2++];
if (c1 != c2) {
@@ -474,7 +360,7 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRUint32 n)
}
}
if (c1 == 0) break;
} while (--n != 0);
}
}
}
return 0;
@@ -482,7 +368,7 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRUint32 n)
PRUnichar* nsCRT::strdup(const PRUnichar* str)
{
PRUint32 len = nsCRT::strlen(str) + 1; // add one for null
PRInt32 len = nsCRT::strlen(str) + 1; // add one for null
PRUnichar* rslt = new PRUnichar[len];
if (rslt == NULL) return NULL;
nsCRT::memcpy(rslt, str, len * sizeof(PRUnichar));
@@ -502,10 +388,10 @@ PRUint32 nsCRT::HashValue(const PRUnichar* us)
return rv;
}
PRUint32 nsCRT::HashValue(const PRUnichar* us, PRUint32* uslenp)
PRUint32 nsCRT::HashValue(const PRUnichar* us, PRInt32* uslenp)
{
PRUint32 rv = 0;
PRUint32 len = 0;
PRInt32 len = 0;
PRUnichar ch;
while ((ch = *us++) != 0) {
// FYI: rv = rv*37 + ch

View File

@@ -23,69 +23,28 @@
#include "plstr.h"
#include "nscore.h"
#define CR '\015'
#define LF '\012'
#define VTAB '\013'
#define FF '\014'
#define TAB '\011'
#define CRLF "\015\012" /* A CR LF equivalent string */
// This macro can be used in a class declaration for classes that want
// to ensure that their instance memory is zeroed.
#define NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW \
void* operator new(size_t sz) { \
void* rv = ::operator new(sz); \
if (rv) { \
nsCRT::zero(rv, sz); \
} \
return rv; \
} \
void operator delete(void* ptr) { \
::operator delete(ptr); \
}
// This macro works with the next macro to declare a non-inlined
// version of the above.
#define NS_DECL_ZEROING_OPERATOR_NEW \
void* operator new(size_t sz); \
void operator delete(void* ptr);
#define NS_IMPL_ZEROING_OPERATOR_NEW(_class) \
void* _class::operator new(size_t sz) { \
void* rv = ::operator new(sz); \
if (rv) { \
nsCRT::zero(rv, sz); \
} \
return rv; \
} \
void _class::operator delete(void* ptr) { \
::operator delete(ptr); \
}
/// This is a wrapper class around all the C runtime functions.
class NS_BASE nsCRT {
public:
/** Copy bytes from aSrc to aDest.
@param aDest the destination address
@param aSrc the source address
@param aCount the number of bytes to copy
*/
static void memcpy(void* aDest, const void* aSrc, PRUint32 aCount) {
static void memcpy(void* aDest, const void* aSrc, PRInt32 aCount) {
::memcpy(aDest, aSrc, (size_t)aCount);
}
static void memmove(void* aDest, const void* aSrc, PRUint32 aCount) {
static void memmove(void* aDest, const void* aSrc, PRInt32 aCount) {
::memmove(aDest, aSrc, (size_t)aCount);
}
static void memset(void* aDest, PRUint8 aByte, PRUint32 aCount) {
static void memset(void* aDest, PRUint8 aByte, PRInt32 aCount) {
::memset(aDest, aByte, aCount);
}
static void zero(void* aDest, PRUint32 aCount) {
static void zero(void* aDest, PRInt32 aCount) {
::memset(aDest, 0, (size_t)aCount);
}
@@ -93,18 +52,13 @@ public:
@param s the string in question
@return the length of s
*/
static PRUint32 strlen(const char* s) {
return PRUint32(::strlen(s));
static PRInt32 strlen(const char* s) {
return PRInt32(::strlen(s));
}
/// Compare s1 and s2.
static PRInt32 strcmp(const char* s1, const char* s2) {
return PRUint32(PL_strcmp(s1, s2));
}
static PRUint32 strncmp(const char* s1, const char* s2,
PRUint32 aMaxLen) {
return PRInt32(PL_strncmp(s1, s2, aMaxLen));
return PRInt32(PL_strcmp(s1, s2));
}
/// Case-insensitive string comparison.
@@ -113,63 +67,40 @@ public:
}
/// Case-insensitive string comparison with length
static PRInt32 strncasecmp(const char* s1, const char* s2, PRUint32 aMaxLen) {
static PRInt32 strncasecmp(const char* s1, const char* s2, PRInt32 aMaxLen) {
return PRInt32(PL_strncasecmp(s1, s2, aMaxLen));
}
static PRInt32 strncmp(const char* s1, const char* s2, PRInt32 aMaxLen) {
return PRInt32(PL_strncmp(s1,s2,aMaxLen));
}
static char* strdup(const char* str) {
return PL_strdup(str);
}
/**
How to use this fancy (thread-safe) version of strtok:
void main( void ) {
printf( "%s\n\nTokens:\n", string );
// Establish string and get the first token:
char* newStr;
token = nsCRT::strtok( string, seps, &newStr );
while( token != NULL ) {
// While there are tokens in "string"
printf( " %s\n", token );
// Get next token:
token = nsCRT::strtok( newStr, seps, &newStr );
}
}
*/
static char* strtok(char* str, const char* delims, char* *newStr);
/// Like strlen except for ucs2 strings
static PRUint32 strlen(const PRUnichar* s);
static PRInt32 strlen(const PRUnichar* s);
/// Like strcmp except for ucs2 strings
static PRInt32 strcmp(const PRUnichar* s1, const PRUnichar* s2);
/// Like strcmp except for ucs2 strings
static PRInt32 strncmp(const PRUnichar* s1, const PRUnichar* s2,
PRUint32 aMaxLen);
PRInt32 aMaxLen);
/// Like strcasecmp except for ucs2 strings
static PRInt32 strcasecmp(const PRUnichar* s1, const PRUnichar* s2);
/// Like strncasecmp except for ucs2 strings
static PRInt32 strncasecmp(const PRUnichar* s1, const PRUnichar* s2,
PRUint32 aMaxLen);
PRInt32 aMaxLen);
/// Like strcmp with a char* and a ucs2 string
static PRInt32 strcmp(const PRUnichar* s1, const char* s2);
/// Like strncmp with a char* and a ucs2 string
static PRInt32 strncmp(const PRUnichar* s1, const char* s2,
PRUint32 aMaxLen);
PRInt32 aMaxLen);
/// Like strcasecmp with a char* and a ucs2 string
static PRInt32 strcasecmp(const PRUnichar* s1, const char* s2);
/// Like strncasecmp with a char* and a ucs2 string
static PRInt32 strncasecmp(const PRUnichar* s1, const char* s2,
PRUint32 aMaxLen);
PRInt32 aMaxLen);
// Note: uses new[] to allocate memory, so you must use delete[] to
// free the memory
@@ -179,7 +110,7 @@ public:
static PRUint32 HashValue(const PRUnichar* s1);
/// Same as above except that we return the length in s1len
static PRUint32 HashValue(const PRUnichar* s1, PRUint32* s1len);
static PRUint32 HashValue(const PRUnichar* s1, PRInt32* s1len);
/// String to integer.
static PRInt32 atoi( const PRUnichar *string );
@@ -187,10 +118,6 @@ public:
static PRUnichar ToUpper(PRUnichar aChar);
static PRUnichar ToLower(PRUnichar aChar);
static PRBool IsUpper(PRUnichar aChar);
static PRBool IsLower(PRUnichar aChar);
};
#endif /* nsCRT_h___ */

View File

@@ -28,8 +28,8 @@
* @update gess4/18/98
* @return new deque
*/
nsDeque::nsDeque(nsDequeFunctor* aDeallocator) {
mDeallocator=aDeallocator;
nsDeque::nsDeque(nsDequeFunctor& aMemDestroyer) : mMemDestroyer(aMemDestroyer) {
mMemDestroyer=aMemDestroyer;
mCapacity=eGrowthDelta;
mOrigin=mSize=0;
mData=new void*[mCapacity];
@@ -44,10 +44,6 @@ nsDeque::~nsDeque() {
Erase();
delete [] mData;
mData=0;
if(mDeallocator) {
delete mDeallocator;
}
mDeallocator=0;
}
@@ -63,13 +59,6 @@ PRInt32 nsDeque::GetSize(void) const {
return mSize;
}
void nsDeque::SetDeallocator(nsDequeFunctor* aDeallocator){
if(mDeallocator) {
delete mDeallocator;
}
mDeallocator=aDeallocator;
}
/**
* Remove all items from container without destroying them.
*
@@ -78,9 +67,7 @@ void nsDeque::SetDeallocator(nsDequeFunctor* aDeallocator){
* @return
*/
nsDeque& nsDeque::Empty() {
if((0<mCapacity) && (mData)) {
nsCRT::zero(mData,mCapacity*sizeof(mData));
}
nsCRT::zero(mData,mCapacity*sizeof(mData));
mSize=0;
mOrigin=0;
return *this;
@@ -93,9 +80,7 @@ nsDeque& nsDeque::Empty() {
* @return this
*/
nsDeque& nsDeque::Erase() {
if(mDeallocator) {
ForEach(*mDeallocator);
}
ForEach(mMemDestroyer);
return Empty();
}

View File

@@ -71,7 +71,7 @@ public:
class NS_BASE nsDeque {
friend class nsDequeIterator;
public:
nsDeque(nsDequeFunctor* aDeallocator);
nsDeque(nsDequeFunctor& aMemDestroyer);
~nsDeque();
/**
@@ -201,8 +201,6 @@ friend class nsDequeIterator;
*/
const void* FirstThat(nsDequeFunctor& aFunctor) const;
void SetDeallocator(nsDequeFunctor* aDeallocator);
/**
* Perform automated selftest on the deque
*
@@ -217,7 +215,7 @@ protected:
PRInt32 mSize;
PRInt32 mCapacity;
PRInt32 mOrigin;
nsDequeFunctor* mDeallocator;
nsDequeFunctor& mMemDestroyer;
void** mData;

View File

@@ -53,7 +53,7 @@ const int netCharType[256] =
#define HEX_ESCAPE '%'
//----------------------------------------------------------------------------------------
NS_BASE char* nsEscape(const char * str, nsEscapeMask mask)
char* nsEscape(const char * str, nsEscapeMask mask)
//----------------------------------------------------------------------------------------
{
if(!str)
@@ -62,64 +62,45 @@ NS_BASE char* nsEscape(const char * str, nsEscapeMask mask)
}
//----------------------------------------------------------------------------------------
NS_BASE char* nsEscapeCount(
const char * str,
PRInt32 len,
nsEscapeMask mask,
PRInt32* out_len)
char* nsEscapeCount(const char * str, PRInt32 len, nsEscapeMask mask, PRInt32 * out_len)
//----------------------------------------------------------------------------------------
{
if (!str)
return 0;
int32 i, extra = 0;
char *hexChars = "0123456789ABCDEF";
int i, extra = 0;
char* hexChars = "0123456789ABCDEF";
if(!str)
return(0);
register const unsigned char* src = (const unsigned char *) str;
register const unsigned char* src = (unsigned char *) str;
for (i = 0; i < len; i++)
{
if (!IS_OK(*src++))
extra += 2; /* the escape, plus an extra byte for each nibble */
}
{
if (!IS_OK(src[i]))
extra+=2; /* the escape, plus an extra byte for each nibble */
}
char* result = new char[len + extra + 1];
if (!result)
return 0;
return(0);
register unsigned char* dst = (unsigned char *) result;
src = (const unsigned char *) str;
if (mask == url_XPAlphas)
{
for (i = 0; i < len; i++)
{
unsigned char c = *src++;
if (IS_OK(c))
*dst++ = c;
else if (c == ' ')
*dst++ = '+'; /* convert spaces to pluses */
else
{
*dst++ = HEX_ESCAPE;
*dst++ = hexChars[c >> 4]; /* high nibble */
*dst++ = hexChars[c & 0x0f]; /* low nibble */
}
}
}
else
{
for (i = 0; i < len; i++)
{
unsigned char c = *src++;
if (IS_OK(c))
*dst++ = c;
else
{
*dst++ = HEX_ESCAPE;
*dst++ = hexChars[c >> 4]; /* high nibble */
*dst++ = hexChars[c & 0x0f]; /* low nibble */
}
}
}
for (i = 0; i < len; i++)
{
unsigned char c = src[i];
if (IS_OK(c))
{
*dst++ = c;
}
else if (mask == url_XPAlphas && c == ' ')
{
*dst++ = '+'; /* convert spaces to pluses */
}
else
{
*dst++ = HEX_ESCAPE;
*dst++ = hexChars[c >> 4]; /* high nibble */
*dst++ = hexChars[c & 0x0f]; /* low nibble */
}
}
*dst = '\0'; /* tack on eos */
if(out_len)
@@ -128,7 +109,7 @@ NS_BASE char* nsEscapeCount(
}
//----------------------------------------------------------------------------------------
NS_BASE char* nsUnescape(char * str)
char* nsUnescape(char * str)
//----------------------------------------------------------------------------------------
{
nsUnescapeCount(str);
@@ -136,7 +117,7 @@ NS_BASE char* nsUnescape(char * str)
}
//----------------------------------------------------------------------------------------
NS_BASE PRInt32 nsUnescapeCount(char * str)
PRInt32 nsUnescapeCount(char * str)
//----------------------------------------------------------------------------------------
{
register char *src = str;
@@ -144,24 +125,27 @@ NS_BASE PRInt32 nsUnescapeCount(char * str)
while (*src)
if (*src != HEX_ESCAPE)
{
*dst++ = *src++;
}
else
{
{
src++; /* walk over escape */
if (*src)
{
{
*dst = UNHEX(*src) << 4;
src++;
}
}
if (*src)
{
{
*dst = (*dst + UNHEX(*src));
src++;
}
}
dst++;
}
}
*dst = 0;
return (int)(dst - str);
} /* NET_UnEscapeCnt */

View File

@@ -20,12 +20,8 @@
#include "nsFileStream.h"
#include "nsDebug.h"
#include "nsEscape.h"
#include "prtypes.h"
#include "plstr.h"
#include "plbase64.h"
#include "prmem.h"
#include <string.h>
#include <stdio.h>
@@ -44,7 +40,7 @@ NS_NAMESPACE nsFileSpecHelpers
char inSeparator,
const char* inLeafName);
#ifndef XP_MAC
NS_NAMESPACE_PROTOTYPE void Canonify(char*& ioPath, PRBool inMakeDirs);
NS_NAMESPACE_PROTOTYPE void Canonify(char*& ioPath, bool inMakeDirs);
NS_NAMESPACE_PROTOTYPE void MakeAllDirectories(const char* inPath, int mode);
#endif
NS_NAMESPACE_PROTOTYPE char* GetLeaf(const char* inPath, char inSeparator); // allocated
@@ -58,14 +54,6 @@ NS_NAMESPACE nsFileSpecHelpers
#endif
} NS_NAMESPACE_END
//----------------------------------------------------------------------------------------
nsresult ns_file_convert_result(PRInt32 nativeErr)
//----------------------------------------------------------------------------------------
{
return nativeErr ?
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_FILES,((nativeErr)&0xFFFF))
: NS_OK;
}
//----------------------------------------------------------------------------------------
char* nsFileSpecHelpers::StringDup(
@@ -77,7 +65,7 @@ char* nsFileSpecHelpers::StringDup(
allocLength = strlen(inString);
char* newPath = inString || allocLength ? new char[allocLength + 1] : nsnull;
if (!newPath)
return nsnull;
return NULL;
strcpy(newPath, inString);
return newPath;
} // nsFileSpecHelpers::StringDup
@@ -89,7 +77,7 @@ char* nsFileSpecHelpers::AllocCat(
//----------------------------------------------------------------------------------------
{
if (!inString1)
return inString2 ? StringDup(inString2) : (char*)nsnull;
return inString2 ? StringDup(inString2) : (char*)NULL;
if (!inString2)
return StringDup(inString1);
char* outString = StringDup(inString1, strlen(inString1) + strlen(inString2));
@@ -107,7 +95,7 @@ char* nsFileSpecHelpers::StringAssign(
if (!inString2)
{
delete [] ioString;
ioString = (char*)nsnull;
ioString = (char*)NULL;
return ioString;
}
if (!ioString || (strlen(inString2) > strlen(ioString)))
@@ -137,19 +125,8 @@ void nsFileSpecHelpers::LeafReplace(
}
char* lastSeparator = strrchr(ioPath, inSeparator);
int oldLength = strlen(ioPath);
PRBool trailingSeparator = (lastSeparator + 1 == ioPath + oldLength);
if (trailingSeparator)
{
*lastSeparator = '\0';
lastSeparator = strrchr(ioPath, inSeparator);
}
if (lastSeparator)
lastSeparator++; // point at the trailing string
else
lastSeparator = ioPath; // the full monty
*lastSeparator = '\0'; // strip the current leaf name
int newLength = (lastSeparator - ioPath) + strlen(inLeafName) + int(trailingSeparator);
*(++lastSeparator) = '\0'; // strip the current leaf name
int newLength = lastSeparator - ioPath + strlen(inLeafName);
if (newLength > oldLength)
{
char* newPath = StringDup(ioPath, newLength + 1);
@@ -157,14 +134,7 @@ void nsFileSpecHelpers::LeafReplace(
ioPath = newPath;
}
strcat(ioPath, inLeafName);
if (trailingSeparator)
{
// If the original ended in a slash, then the new one should, too.
char sepStr[2] = "/";
*sepStr = inSeparator;
strcat(ioPath, sepStr);
}
} // nsFileSpecHelpers::LeafReplace
} // nsNativeFileSpec::LeafReplace
//----------------------------------------------------------------------------------------
char* nsFileSpecHelpers::GetLeaf(const char* inPath, char inSeparator)
@@ -172,32 +142,12 @@ char* nsFileSpecHelpers::GetLeaf(const char* inPath, char inSeparator)
//----------------------------------------------------------------------------------------
{
if (!inPath)
return nsnull;
const char* lastSeparator = strrchr(inPath, inSeparator);
// If there was no separator, then return a copy of the caller's path.
if (!lastSeparator)
return StringDup(inPath);
// So there's at least one separator. What's just after it?
// If the separator was not the last character, return the trailing string.
const char* leafPointer = lastSeparator + 1;
if (*leafPointer)
return StringDup(leafPointer);
// So now, separator was the last character. Poke in a null instead.
*(char*)lastSeparator = '\0'; // Should use const_cast, but Unix has old compiler.
leafPointer = strrchr(inPath, inSeparator);
char* result = leafPointer ? StringDup(++leafPointer) : StringDup(inPath);
// Restore the poked null before returning.
*(char*)lastSeparator = inSeparator;
#ifdef XP_PC
// If it's a drive letter use the colon notation.
if (!leafPointer && strlen(result) == 2 && result[1] == '|')
result[1] = ':';
#endif
return result;
} // nsFileSpecHelpers::GetLeaf
return NULL;
char* lastSeparator = strrchr(inPath, inSeparator);
if (lastSeparator)
return StringDup(++lastSeparator);
return StringDup(inPath);
} // nsNativeFileSpec::GetLeaf
#if defined(XP_UNIX) || defined(XP_PC)
@@ -226,33 +176,9 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode)
char* currentEnd = strchr(currentStart + kSkipFirst, kSeparator);
if (currentEnd)
{
nsFileSpec spec;
*currentEnd = '\0';
#ifdef XP_PC
/*
if we have a drive letter path, we must make sure that the inital path has a '/' on it, or
Canonify will turn "/c|" into a path relative to the running executable.
*/
if (pathCopy[0] == '/' && pathCopy[2] == '|')
{
char* startDir = nsFileSpecHelpers::StringDup( pathCopy, (strlen(pathCopy) + 1) );
strcat(startDir, "/");
spec = nsFilePath(startDir, PR_FALSE);
delete [] startDir;
}
else
{
spec = nsFilePath(pathCopy, PR_FALSE);
}
#else
spec = nsFilePath(pathCopy, PR_FALSE);
#endif
do
nsNativeFileSpec spec(nsFilePath(pathCopy, false));
do
{
// If the node doesn't exist, and it is not the initial node in a full path,
// then make a directory (We cannot make the initial (volume) node).
@@ -267,9 +193,6 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode)
currentEnd = strchr(currentStart, kSeparator);
if (!currentEnd)
break;
*currentEnd = '\0';
spec += currentStart; // "lengthen" the path, adding the next node.
} while (currentEnd);
}
@@ -286,7 +209,7 @@ char* nsFileSpecHelpers::ReallocCat(char*& ioString, const char* inString1)
delete [] ioString;
ioString = newString;
return ioString;
} // nsFileSpecHelpers::ReallocCat
} // nsNativeFileSpec::ReallocCat
#if defined(XP_PC)
#include "windows/nsFileSpecWin.cpp" // Windows-specific implementations
@@ -302,7 +225,7 @@ char* nsFileSpecHelpers::ReallocCat(char*& ioString, const char* inString1)
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
nsFileURL::nsFileURL(const char* inString, PRBool inCreateDirs)
nsFileURL::nsFileURL(const char* inString, bool inCreateDirs)
//----------------------------------------------------------------------------------------
: mURL(nsnull)
{
@@ -315,52 +238,35 @@ nsFileURL::nsFileURL(const char* inString, PRBool inCreateDirs)
} // nsFileURL::nsFileURL
#endif
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
nsFileURL::nsFileURL(const nsString& inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
: mURL(nsnull)
{
const nsAutoCString aString(inString);
const char* aCString = (const char*) aString;
if (!inString)
return;
NS_ASSERTION(strstr(aCString, kFileURLPrefix) == aCString, "Not a URL!");
// Make canonical and absolute.
nsFilePath path(aCString + kFileURLPrefixLength, inCreateDirs);
*this = path;
} // nsFileURL::nsFileURL
#endif
//----------------------------------------------------------------------------------------
nsFileURL::nsFileURL(const nsFileURL& inOther)
//----------------------------------------------------------------------------------------
: mURL(nsFileSpecHelpers::StringDup(inOther.mURL))
#ifdef XP_MAC
, mFileSpec(inOther.GetFileSpec())
, mNativeFileSpec(inOther.GetNativeSpec())
#endif
{
} // nsFileURL::nsFileURL
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
nsFileURL::nsFileURL(const nsFilePath& inOther)
//----------------------------------------------------------------------------------------
: mURL(nsnull)
{
*this = inOther;
} // nsFileURL::nsFileURL
: mURL(nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)inOther))
#ifdef XP_MAC
, mNativeFileSpec(inOther.GetNativeSpec())
#endif
{
} // nsFileURL::nsFileURL
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
nsFileURL::nsFileURL(const nsFileSpec& inOther)
: mURL(nsnull)
nsFileURL::nsFileURL(const nsNativeFileSpec& inOther)
: mURL(nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)nsFilePath(inOther)))
#ifdef XP_MAC
, mNativeFileSpec(inOther)
#endif
//----------------------------------------------------------------------------------------
{
*this = inOther;
} // nsFileURL::nsFileURL
#endif
//----------------------------------------------------------------------------------------
nsFileURL::~nsFileURL()
@@ -369,15 +275,16 @@ nsFileURL::~nsFileURL()
delete [] mURL;
}
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
void nsFileURL::operator = (const char* inString)
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(mURL, inString);
NS_ASSERTION(strstr(inString, kFileURLPrefix) == inString, "Not a URL!");
} // nsFileURL::operator =
#ifdef XP_MAC
mNativeFileSpec = inString + kFileURLPrefixLength;
#endif
} // nsFileURL::operator =
//----------------------------------------------------------------------------------------
void nsFileURL::operator = (const nsFileURL& inOther)
@@ -385,44 +292,34 @@ void nsFileURL::operator = (const nsFileURL& inOther)
{
mURL = nsFileSpecHelpers::StringAssign(mURL, inOther.mURL);
#ifdef XP_MAC
mFileSpec = inOther.GetFileSpec();
mNativeFileSpec = inOther.GetNativeSpec();
#endif
} // nsFileURL::operator =
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
void nsFileURL::operator = (const nsFilePath& inOther)
//----------------------------------------------------------------------------------------
{
delete [] mURL;
char* original = (char*)(const char*)inOther; // we shall modify, but restore.
#ifdef XP_PC
// because we don't want to escape the '|' character, change it to a letter.
NS_ASSERTION(original[2] == '|', "No drive letter part!");
original[2] = 'x';
char* escapedPath = nsEscape(original, url_Path);
original[2] = '|'; // restore it
escapedPath[2] = '|';
#else
char* escapedPath = nsEscape(original, url_Path);
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)inOther);
#ifdef XP_MAC
mNativeFileSpec = inOther.GetNativeSpec();
#endif
if (escapedPath)
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, escapedPath);
delete [] escapedPath;
} // nsFileURL::operator =
#endif
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
void nsFileURL::operator = (const nsFileSpec& inOther)
void nsFileURL::operator = (const nsNativeFileSpec& inOther)
//----------------------------------------------------------------------------------------
{
*this = nsFilePath(inOther);
} // nsFileURL::operator =
delete [] mURL;
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)nsFilePath(inOther));
#ifdef XP_MAC
mNativeFileSpec = inOther;
#endif
} // nsFileURL::operator =
//----------------------------------------------------------------------------------------
nsOutputStream& operator << (nsOutputStream& s, const nsFileURL& url)
nsBasicOutStream& operator << (nsBasicOutStream& s, const nsFileURL& url)
//----------------------------------------------------------------------------------------
{
return (s << url.mURL);
@@ -432,17 +329,9 @@ nsOutputStream& operator << (nsOutputStream& s, const nsFileURL& url)
// nsFilePath implementation
//========================================================================================
nsFilePath::nsFilePath(const nsFilePath& inPath)
: mPath(nsFileSpecHelpers::StringDup(inPath.mPath))
#ifdef XP_MAC
, mFileSpec(inPath.mFileSpec)
#endif
{
}
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const char* inString, PRBool inCreateDirs)
nsFilePath::nsFilePath(const char* inString, bool inCreateDirs)
//----------------------------------------------------------------------------------------
: mPath(nsFileSpecHelpers::StringDup(inString))
{
@@ -460,38 +349,19 @@ nsFilePath::nsFilePath(const char* inString, PRBool inCreateDirs)
}
#endif
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
: mPath(inString.ToNewCString())
{
NS_ASSERTION(strstr(mPath, kFileURLPrefix) != mPath, "URL passed as path");
#ifdef XP_PC
nsFileSpecHelpers::UnixToNative(mPath);
#endif
// Make canonical and absolute.
nsFileSpecHelpers::Canonify(mPath, inCreateDirs);
#ifdef XP_PC
NS_ASSERTION( mPath[1] == ':', "unexpected canonical path" );
nsFileSpecHelpers::NativeToUnix(mPath);
#endif
}
#endif
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const nsFileURL& inOther)
//----------------------------------------------------------------------------------------
: mPath(nsFileSpecHelpers::StringDup(inOther.mURL + kFileURLPrefixLength))
#ifdef XP_MAC
, mNativeFileSpec(inOther.GetNativeSpec())
#endif
{
}
#endif
#ifdef XP_UNIX
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const nsFileSpec& inOther)
nsFilePath::nsFilePath(const nsNativeFileSpec& inOther)
//----------------------------------------------------------------------------------------
: mPath(nsFileSpecHelpers::StringDup(inOther.mPath))
{
@@ -507,7 +377,7 @@ nsFilePath::~nsFilePath()
#ifdef XP_UNIX
//----------------------------------------------------------------------------------------
void nsFilePath::operator = (const nsFileSpec& inOther)
void nsFilePath::operator = (const nsNativeFileSpec& inOther)
//----------------------------------------------------------------------------------------
{
mPath = nsFileSpecHelpers::StringAssign(mPath, inOther.mPath);
@@ -520,82 +390,65 @@ void nsFilePath::operator = (const char* inString)
{
NS_ASSERTION(strstr(inString, kFileURLPrefix) != inString, "URL passed as path");
#ifdef XP_MAC
mFileSpec = inString;
nsFileSpecHelpers::StringAssign(mPath, (const char*)nsFilePath(mFileSpec));
mNativeFileSpec = inString;
nsFileSpecHelpers::StringAssign(mPath, (const char*)nsFilePath(mNativeFileSpec));
#else
nsFileSpecHelpers::StringAssign(mPath, inString);
#ifdef XP_PC
nsFileSpecHelpers::UnixToNative(mPath);
#endif
// Make canonical and absolute.
nsFileSpecHelpers::Canonify(mPath, PR_FALSE /* XXX? */);
nsFileSpecHelpers::Canonify(mPath, false /* XXX? */);
#ifdef XP_PC
nsFileSpecHelpers::NativeToUnix(mPath);
#endif
#endif // XP_MAC
}
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
void nsFilePath::operator = (const nsFileURL& inOther)
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(mPath, (const char*)nsFilePath(inOther));
}
#endif
//----------------------------------------------------------------------------------------
void nsFilePath::operator = (const nsFilePath& inOther)
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(mPath, inOther.mPath);
#ifdef XP_MAC
mFileSpec = inOther.GetFileSpec();
mNativeFileSpec = inOther.GetNativeSpec();
#endif
}
//========================================================================================
// nsFileSpec implementation
// nsNativeFileSpec implementation
//========================================================================================
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec()
nsNativeFileSpec::nsNativeFileSpec()
//----------------------------------------------------------------------------------------
: mPath(nsnull)
, mError(NS_OK)
: mPath(NULL)
{
}
#endif
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsPersistentFileDescriptor& inDescriptor)
nsNativeFileSpec::nsNativeFileSpec(const nsFileURL& inURL)
//----------------------------------------------------------------------------------------
: mPath(nsnull)
{
*this = inDescriptor;
}
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsFileURL& inURL)
//----------------------------------------------------------------------------------------
: mPath(nsnull)
#ifndef XP_MAC
: mPath(NULL)
#endif
{
*this = nsFilePath(inURL); // convert to unix path first
}
//----------------------------------------------------------------------------------------
void nsFileSpec::MakeUnique(const char* inSuggestedLeafName)
void nsNativeFileSpec::MakeUnique(const char* inSuggestedLeafName)
//----------------------------------------------------------------------------------------
{
if (inSuggestedLeafName && *inSuggestedLeafName)
SetLeafName(inSuggestedLeafName);
MakeUnique();
} // nsFileSpec::MakeUnique
} // nsNativeFileSpec::MakeUnique
//----------------------------------------------------------------------------------------
void nsFileSpec::MakeUnique()
void nsNativeFileSpec::MakeUnique()
//----------------------------------------------------------------------------------------
{
if (!Exists())
@@ -614,7 +467,7 @@ void nsFileSpec::MakeUnique()
}
const int kMaxRootLength
= nsFileSpecHelpers::kMaxCoreLeafNameLength - strlen(suffix) - 1;
if ((int)strlen(leafName) > (int)kMaxRootLength)
if (strlen(leafName) > kMaxRootLength)
leafName[kMaxRootLength] = '\0';
for (short index = 1; index < 1000 && Exists(); index++)
{
@@ -626,95 +479,51 @@ void nsFileSpec::MakeUnique()
if (*suffix)
delete [] suffix;
delete [] leafName;
} // nsFileSpec::MakeUnique
} // nsNativeFileSpec::MakeUnique
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const nsFileURL& inURL)
void nsNativeFileSpec::operator = (const nsFileURL& inURL)
//----------------------------------------------------------------------------------------
{
*this = nsFilePath(inURL); // convert to unix path first
}
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const nsPersistentFileDescriptor& inDescriptor)
//----------------------------------------------------------------------------------------
{
void* data;
PRInt32 dataSize;
inDescriptor.GetData(data, dataSize);
#ifdef XP_MAC
char* decodedData = PL_Base64Decode((const char*)data, (int)dataSize, nsnull);
// Cast to an alias record and resolve.
AliasHandle aliasH = nsnull;
mError = NS_FILE_RESULT(PtrToHand(decodedData, &(Handle)aliasH, (dataSize * 3) / 4));
PR_Free(decodedData);
if (NS_SUCCEEDED(mError))
return; // not enough memory?
Boolean changed;
mError = NS_FILE_RESULT(::ResolveAlias(nsnull, aliasH, &mSpec, &changed));
DisposeHandle((Handle) aliasH);
delete [] mPath;
#else
nsFileSpecHelpers::StringAssign(mPath, (char*)data);
mError = NS_OK;
#endif
}
//========================================================================================
// UNIX & WIN nsFileSpec implementation
// UNIX & WIN nsNativeFileSpec implementation
//========================================================================================
#ifdef XP_UNIX
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsFilePath& inPath)
nsNativeFileSpec::nsNativeFileSpec(const nsFilePath& inPath)
//----------------------------------------------------------------------------------------
: mPath(nsFileSpecHelpers::StringDup((const char*)inPath))
, mError(NS_OK)
{
}
#endif // XP_UNIX
#ifdef XP_UNIX
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const nsFilePath& inPath)
void nsNativeFileSpec::operator = (const nsFilePath& inPath)
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(mPath, (const char*)inPath);
mError = NS_OK;
}
#endif //XP_UNIX
#if defined(XP_UNIX) || defined(XP_PC)
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsFileSpec& inSpec)
nsNativeFileSpec::nsNativeFileSpec(const nsNativeFileSpec& inSpec)
//----------------------------------------------------------------------------------------
: mPath(nsFileSpecHelpers::StringDup(inSpec.mPath))
, mError(NS_OK)
{
}
#endif //XP_UNIX
#if defined(XP_UNIX) || defined(XP_PC)
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const char* inString, PRBool inCreateDirs)
nsNativeFileSpec::nsNativeFileSpec(const char* inString, bool inCreateDirs)
//----------------------------------------------------------------------------------------
: mPath(nsFileSpecHelpers::StringDup(inString))
, mError(NS_OK)
{
// Make canonical and absolute.
nsFileSpecHelpers::Canonify(mPath, inCreateDirs);
}
#endif //XP_UNIX,PC
#if defined(XP_UNIX) || defined(XP_PC)
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsString& inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
: mPath(inString.ToNewCString())
, mError(NS_OK)
{
// Make canonical and absolute.
nsFileSpecHelpers::Canonify(mPath, inCreateDirs);
@@ -722,254 +531,49 @@ nsFileSpec::nsFileSpec(const nsString& inString, PRBool inCreateDirs)
#endif //XP_UNIX,PC
//----------------------------------------------------------------------------------------
nsFileSpec::~nsFileSpec()
nsNativeFileSpec::~nsNativeFileSpec()
//----------------------------------------------------------------------------------------
{
#ifndef XP_MAC
delete [] mPath;
#endif
}
#if defined(XP_UNIX) || defined(XP_PC)
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const nsFileSpec& inSpec)
void nsNativeFileSpec::operator = (const nsNativeFileSpec& inSpec)
//----------------------------------------------------------------------------------------
{
mPath = nsFileSpecHelpers::StringAssign(mPath, inSpec.mPath);
mError = inSpec.Error();
}
#endif //XP_UNIX
#if defined(XP_UNIX) || defined(XP_PC)
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const char* inString)
void nsNativeFileSpec::operator = (const char* inString)
//----------------------------------------------------------------------------------------
{
mPath = nsFileSpecHelpers::StringAssign(mPath, inString);
// Make canonical and absolute.
nsFileSpecHelpers::Canonify(mPath, PR_FALSE /* XXX? */);
mError = NS_OK;
nsFileSpecHelpers::Canonify(mPath, true /* XXX? */);
}
#endif //XP_UNIX
#if (defined(XP_UNIX) || defined(XP_PC))
//----------------------------------------------------------------------------------------
nsOutputStream& operator << (nsOutputStream& s, const nsFileSpec& spec)
nsBasicOutStream& operator << (nsBasicOutStream& s, const nsNativeFileSpec& spec)
//----------------------------------------------------------------------------------------
{
#ifdef NS_DEBUG
static PRBool warnedOnce = PR_FALSE;
if (!warnedOnce)
{
NS_WARNING("This is for debugging only. Do not call this in shipped version!");
warnedOnce = PR_TRUE;
}
#endif // NS_DEBUG
return (s << spec.GetCString());
return (s << (const char*)spec.mPath);
}
#endif // DEBUG ONLY!
#endif // DEBUG && XP_UNIX
//----------------------------------------------------------------------------------------
nsFileSpec nsFileSpec::operator + (const char* inRelativePath) const
nsNativeFileSpec nsNativeFileSpec::operator + (const char* inRelativePath) const
//----------------------------------------------------------------------------------------
{
nsFileSpec result = *this;
nsNativeFileSpec result = *this;
result += inRelativePath;
return result;
} // nsFileSpec::operator +
//----------------------------------------------------------------------------------------
PRBool nsFileSpec::operator == (const nsFileSpec& inOther) const
//----------------------------------------------------------------------------------------
{
#ifdef XP_MAC
if ( inOther.mSpec.vRefNum == mSpec.vRefNum &&
inOther.mSpec.parID == mSpec.parID &&
EqualString(inOther.mSpec.name, mSpec.name, false, true))
return PR_TRUE;
#else
PRBool amEmpty = !mPath || !*mPath;
PRBool heEmpty = !inOther.mPath || !*inOther.mPath;
if (amEmpty) // we're the same if he's empty...
return heEmpty;
if (heEmpty) // ('cuz I'm not...)
return PR_FALSE;
#if defined(XP_PC)
// windows does not care about case.
if (_stricmp(mPath, inOther.mPath ) == 0)
return PR_TRUE;
#else
if (strcmp(mPath, inOther.mPath ) == 0)
return PR_TRUE;
#endif
#endif
return PR_FALSE;
}
//----------------------------------------------------------------------------------------
PRBool nsFileSpec::operator != (const nsFileSpec& inOther) const
//----------------------------------------------------------------------------------------
{
return (! (*this == inOther) );
}
#ifndef XP_MAC
//----------------------------------------------------------------------------------------
const char* nsFileSpec::GetCString() const
// This is the only automatic conversion to const char*
// that is provided, and it allows the
// path to be "passed" to NSPR file routines. This practice
// is VERY EVIL and should only be used to support legacy
// code. Using it guarantees bugs on Macintosh. The path is NOT allocated, so do
// not even think of deleting (or freeing) it.
//----------------------------------------------------------------------------------------
{
return mPath;
}
#endif
//========================================================================================
// class nsPersistentFileDescriptor
//========================================================================================
//----------------------------------------------------------------------------------------
nsPersistentFileDescriptor::nsPersistentFileDescriptor(const nsPersistentFileDescriptor& inDesc)
//----------------------------------------------------------------------------------------
: mDescriptorString(nsFileSpecHelpers::StringDup(inDesc.mDescriptorString))
{
} // nsPersistentFileDescriptor::nsPersistentFileDescriptor
//----------------------------------------------------------------------------------------
void nsPersistentFileDescriptor::operator = (const nsPersistentFileDescriptor& inDesc)
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(mDescriptorString, inDesc.mDescriptorString);
} // nsPersistentFileDescriptor::operator =
//----------------------------------------------------------------------------------------
nsPersistentFileDescriptor::nsPersistentFileDescriptor(const nsFileSpec& inSpec)
//----------------------------------------------------------------------------------------
: mDescriptorString(nsnull)
{
*this = inSpec;
} // nsPersistentFileDescriptor::nsPersistentFileDescriptor
//----------------------------------------------------------------------------------------
void nsPersistentFileDescriptor::operator = (const nsFileSpec& inSpec)
//----------------------------------------------------------------------------------------
{
#ifdef XP_MAC
if (inSpec.Error())
return;
AliasHandle aliasH;
OSErr err = NewAlias(nil, inSpec.GetFSSpecPtr(), &aliasH);
if (err != noErr)
return;
PRUint32 bytes = GetHandleSize((Handle) aliasH);
HLock((Handle) aliasH);
char* buf = PL_Base64Encode((const char*)*aliasH, bytes, nsnull);
DisposeHandle((Handle) aliasH);
nsFileSpecHelpers::StringAssign(mDescriptorString, buf);
PR_Free(buf);
#else
nsFileSpecHelpers::StringAssign(mDescriptorString, inSpec.GetCString());
#endif // XP_MAC
} // nsPersistentFileDescriptor::operator =
//----------------------------------------------------------------------------------------
nsPersistentFileDescriptor::~nsPersistentFileDescriptor()
//----------------------------------------------------------------------------------------
{
delete [] mDescriptorString;
} // nsPersistentFileDescriptor::~nsPersistentFileDescriptor
//----------------------------------------------------------------------------------------
void nsPersistentFileDescriptor::GetData(void*& outData, PRInt32& outSize) const
//----------------------------------------------------------------------------------------
{
outSize = PL_strlen(mDescriptorString);
outData = mDescriptorString;
}
//----------------------------------------------------------------------------------------
void nsPersistentFileDescriptor::SetData(const void* inData, PRInt32 inSize)
//----------------------------------------------------------------------------------------
{
delete [] mDescriptorString;
mDescriptorString = new char[1 + inSize];
if (!mDescriptorString)
return;
memcpy(mDescriptorString, inData, inSize);
mDescriptorString[inSize] = '\0';
}
#define MAX_PERSISTENT_DATA_SIZE 1000
//----------------------------------------------------------------------------------------
nsresult nsPersistentFileDescriptor::Read(nsIInputStream* aStream)
//----------------------------------------------------------------------------------------
{
nsInputStream inputStream(aStream);
inputStream >> *this;
return NS_OK;
}
//----------------------------------------------------------------------------------------
nsresult nsPersistentFileDescriptor::Write(nsIOutputStream* aStream)
//----------------------------------------------------------------------------------------
{
nsOutputStream outputStream(aStream);
outputStream << *this;
return NS_OK;
}
//----------------------------------------------------------------------------------------
nsInputStream& operator >> (nsInputStream& s, nsPersistentFileDescriptor& d)
// reads the data from a file
//----------------------------------------------------------------------------------------
{
char bigBuffer[MAX_PERSISTENT_DATA_SIZE + 1];
// The first 8 bytes of the data should be a hex version of the data size to follow.
PRInt32 bytesRead = 8;
bytesRead = s.read(bigBuffer, bytesRead);
if (bytesRead != 8)
return s;
bigBuffer[8] = '\0';
sscanf(bigBuffer, "%lx", (PRUint32*)&bytesRead);
if (bytesRead > MAX_PERSISTENT_DATA_SIZE)
return s; // preposterous.
// Now we know how many bytes to read, do it.
s.read(bigBuffer, bytesRead);
d.SetData(bigBuffer, bytesRead);
return s;
}
//----------------------------------------------------------------------------------------
nsOutputStream& operator << (nsOutputStream& s, const nsPersistentFileDescriptor& d)
// writes the data to a file
//----------------------------------------------------------------------------------------
{
char littleBuf[9];
PRInt32 dataSize;
void* data;
d.GetData(data, dataSize);
// First write (in hex) the length of the data to follow. Exactly 8 bytes
sprintf(littleBuf, "%0.8x", dataSize);
s << littleBuf;
// Now write the data itself
s << d.mDescriptorString;
return s;
}
//========================================================================================
// class nsAutoCString
//========================================================================================
//----------------------------------------------------------------------------------------
nsAutoCString::~nsAutoCString()
//----------------------------------------------------------------------------------------
{
delete [] (char*)mCString;
}
} // nsNativeFileSpec::operator +

View File

@@ -22,256 +22,272 @@
#include "nsFileStream.h"
#include "nsIStringStream.h"
#include <string.h>
#include <stdio.h>
#ifdef XP_MAC
#include <Errors.h>
#endif
//========================================================================================
// nsInputStream
// nsBasicFileStream
//========================================================================================
//----------------------------------------------------------------------------------------
nsInputStream::~nsInputStream()
nsBasicFileStream::nsBasicFileStream()
//----------------------------------------------------------------------------------------
: mFileDesc(0)
, mNSPRMode(0)
, mFailed(false)
, mEOF(false)
{
}
//----------------------------------------------------------------------------------------
char nsInputStream::get()
nsBasicFileStream::nsBasicFileStream(
const nsFilePath& inFile,
int nsprMode,
PRIntn accessMode)
//----------------------------------------------------------------------------------------
: mFileDesc(0)
, mNSPRMode(0)
, mFailed(false)
, mEOF(false)
{
char c;
read(&c, sizeof(c));
return c;
open(inFile, nsprMode, accessMode);
}
//----------------------------------------------------------------------------------------
PRInt32 nsInputStream::read(void* s, PRInt32 n)
nsBasicFileStream::nsBasicFileStream(PRFileDesc* desc, int nsprMode)
//----------------------------------------------------------------------------------------
: mFileDesc(desc)
, mNSPRMode(nsprMode)
, mFailed(false)
, mEOF(false)
{
if (!mInputStream)
return 0;
PRInt32 result = 0;
mInputStream->Read((char*)s, n, (PRUint32*)&result);
if (result < n)
set_at_eof(PR_TRUE);
return result;
} // nsInputStream::read
//----------------------------------------------------------------------------------------
static void TidyEndOfLine(char*& cp)
// Assumes that cp is pointing at \n or \r. Nulls out the character, checks for
// a second terminator (of the opposite persuasion), and returns cp pointing past the
// entire eol construct (one or two characters).
//----------------------------------------------------------------------------------------
{
char ch = *cp;
*cp++ = '\0'; // terminate at the newline, then skip past it
if ((ch == '\n' && *cp == '\r') || (ch == '\r' && *cp == '\n'))
cp++; // possibly a pair.
}
//----------------------------------------------------------------------------------------
nsInputStream& nsInputStream::operator >> (char& c)
nsBasicFileStream::~nsBasicFileStream()
//----------------------------------------------------------------------------------------
{
c = get();
return *this;
close();
}
//----------------------------------------------------------------------------------------
void nsBasicFileStream::open(
const nsFilePath& inFile,
int nsprMode,
PRIntn accessMode)
//----------------------------------------------------------------------------------------
{
if (mFileDesc)
return;
const int nspr_modes[]={
PR_WRONLY | PR_CREATE_FILE,
PR_WRONLY | PR_CREATE_FILE | PR_APPEND,
PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
PR_RDONLY,
PR_RDONLY | PR_APPEND,
PR_RDWR | PR_CREATE_FILE,
PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE,
// "wb",
// "ab",
// "wb",
// "rb",
// "r+b",
// "w+b",
0 };
const int* currentLegalMode = nspr_modes;
while (*currentLegalMode && nsprMode != *currentLegalMode)
++currentLegalMode;
if (!*currentLegalMode)
return;
#ifdef XP_MAC
// Use the file spec to open the file, because one path can be common to
// several files on the Macintosh (you can have several volumes with the
// same name, see).
mFileDesc = 0;
if (inFile.GetNativeSpec().Error() != noErr)
return;
OSErr err = noErr;
#if DEBUG
const OSType kCreator = 'CWIE';
#else
const OSType kCreator = 'MOSS';
#endif
nsNativeFileSpec nativeSpec = inFile.GetNativeSpec();
FSSpec* spec = (FSSpec*)nativeSpec;
if (nsprMode & PR_CREATE_FILE)
err = FSpCreate(spec, kCreator, 'TEXT', 0);
if (err == dupFNErr)
err = noErr;
if (err != noErr)
return;
SInt8 perm;
if (nsprMode & PR_RDWR)
perm = fsRdWrPerm;
else if (nsprMode & PR_WRONLY)
perm = fsWrPerm;
else
perm = fsRdPerm;
short refnum;
err = FSpOpenDF(spec, perm, &refnum);
if (err == noErr && (nsprMode & PR_TRUNCATE))
err = SetEOF(refnum, 0);
if (err == noErr && (nsprMode & PR_APPEND))
err = SetFPos(refnum, fsFromLEOF, 0);
if (err != noErr)
return;
if ((mFileDesc = PR_ImportFile(refnum)) == 0)
return;
#else
// Platforms other than Macintosh...
// Another bug in NSPR: Mac PR_Open assumes a unix style path, but Win PR_Open assumes
// a windows path.
if ((mFileDesc = PR_Open((const char*)nsNativeFileSpec(inFile), nsprMode, accessMode)) == 0)
return;
#endif
mNSPRMode = nsprMode;
} // nsFileStreamHelpers::open
//----------------------------------------------------------------------------------------
void nsBasicFileStream::close()
// Must precede the destructor because both are inline.
//----------------------------------------------------------------------------------------
{
if (mFileDesc==PR_STDIN || mFileDesc==PR_STDOUT || mFileDesc==PR_STDERR || mFileDesc == 0)
return;
if (PR_Close(mFileDesc) == PR_SUCCESS)
mFileDesc = 0;
} // nsBasicFileStream::close
//----------------------------------------------------------------------------------------
void nsBasicFileStream::seek(PRSeekWhence whence, PRInt32 offset)
// Must precede the destructor because both are inline.
//----------------------------------------------------------------------------------------
{
if (mFileDesc==PR_STDIN || mFileDesc==PR_STDOUT || mFileDesc==PR_STDERR || mFileDesc == 0)
return;
mFailed = false; // reset on a seek.
mEOF = false; // reset on a seek.
PRInt32 position = PR_Seek(mFileDesc, 0, PR_SEEK_CUR);
PRInt32 available = PR_Available(mFileDesc);
PRInt32 fileSize = position + available;
PRInt32 newPosition;
switch (whence)
{
case PR_SEEK_CUR: newPosition = position + offset; break;
case PR_SEEK_SET: newPosition = offset; break;
case PR_SEEK_END: newPosition = fileSize + offset; break;
}
if (newPosition < 0)
{
newPosition = 0;
mFailed = true;
}
else if (newPosition >= fileSize)
{
newPosition = fileSize;
mEOF = true;
}
if (PR_Seek(mFileDesc, newPosition, PR_SEEK_SET) < 0)
mFailed = true;
} // nsBasicFileStream::seek
//----------------------------------------------------------------------------------------
PRIntn nsBasicFileStream::tell() const
// Must precede the destructor because both are inline.
//----------------------------------------------------------------------------------------
{
if (mFileDesc==PR_STDIN || mFileDesc==PR_STDOUT || mFileDesc==PR_STDERR || mFileDesc == 0)
return -1;
return PR_Seek(mFileDesc, 0, PR_SEEK_CUR);
} // nsBasicFileStream::tell
//========================================================================================
// nsOutputStream
// nsBasicInStream
//========================================================================================
//----------------------------------------------------------------------------------------
nsOutputStream::~nsOutputStream()
nsBasicInStream::nsBasicInStream(nsBasicFileStream& inBasicStream, istream* inStream)
//----------------------------------------------------------------------------------------
: mBase(inBasicStream)
, mStdStream(inStream)
{
}
//----------------------------------------------------------------------------------------
void nsBasicInStream::get(char& c)
//----------------------------------------------------------------------------------------
{
read(&c, sizeof(char));
}
//----------------------------------------------------------------------------------------
void nsOutputStream::put(char c)
//----------------------------------------------------------------------------------------
{
write(&c, sizeof(c));
}
//----------------------------------------------------------------------------------------
PRInt32 nsOutputStream::write(const void* s, PRInt32 n)
//----------------------------------------------------------------------------------------
{
if (!mOutputStream)
return 0;
PRInt32 result = 0;
mOutputStream->Write((char*)s, n, (PRUint32*)&result);
return result;
} // nsOutputStream::write
//----------------------------------------------------------------------------------------
void nsOutputStream::flush()
//----------------------------------------------------------------------------------------
{
}
//----------------------------------------------------------------------------------------
nsOutputStream& nsOutputStream::operator << (char c)
//----------------------------------------------------------------------------------------
{
put(c);
return *this;
}
//----------------------------------------------------------------------------------------
nsOutputStream& nsOutputStream::operator << (const char* s)
//----------------------------------------------------------------------------------------
{
write(s, strlen(s));
return *this;
}
//----------------------------------------------------------------------------------------
nsOutputStream& nsOutputStream::operator << (short val)
//----------------------------------------------------------------------------------------
{
char buf[30];
sprintf(buf, "%hd", val);
return (*this << buf);
}
//----------------------------------------------------------------------------------------
nsOutputStream& nsOutputStream::operator << (unsigned short val)
//----------------------------------------------------------------------------------------
{
char buf[30];
sprintf(buf, "%hu", val);
return (*this << buf);
}
//----------------------------------------------------------------------------------------
nsOutputStream& nsOutputStream::operator << (long val)
//----------------------------------------------------------------------------------------
{
char buf[30];
sprintf(buf, "%ld", val);
return (*this << buf);
}
//----------------------------------------------------------------------------------------
nsOutputStream& nsOutputStream::operator << (unsigned long val)
//----------------------------------------------------------------------------------------
{
char buf[30];
sprintf(buf, "%lu", val);
return (*this << buf);
}
//----------------------------------------------------------------------------------------
nsOutputStream& nsOutputStream::operator << (int val)
//----------------------------------------------------------------------------------------
{
char buf[30];
sprintf(buf, "%d", val);
return (*this << buf);
}
//----------------------------------------------------------------------------------------
nsOutputStream& nsOutputStream::operator << (unsigned int val)
//----------------------------------------------------------------------------------------
{
char buf[30];
sprintf(buf, "%u", val);
return (*this << buf);
}
//========================================================================================
// nsRandomAccessInputStream
//========================================================================================
//----------------------------------------------------------------------------------------
PRBool nsRandomAccessInputStream::readline(char* s, PRInt32 n)
PRBool nsBasicInStream::readline(char* s, PRInt32 n)
// This will truncate if the buffer is too small. Result will always be null-terminated.
//----------------------------------------------------------------------------------------
{
PRBool bufferLargeEnough = PR_TRUE; // result
PRBool bufferLargeEnough = true; // result
if (!s || !n)
return PR_TRUE;
PRIntn position = tell();
return true;
PRIntn position = mBase.tell();
if (position < 0)
return PR_FALSE;
return false;
PRInt32 bytesRead = read(s, n - 1);
if (failed())
return PR_FALSE;
if (mBase.failed())
return false;
s[bytesRead] = '\0'; // always terminate at the end of the buffer
char* tp = strpbrk(s, "\n\r");
if (tp)
{
TidyEndOfLine(tp);
char ch = *tp;
*tp++ = '\0'; // terminate at the newline, then skip past it
if ((ch == '\n' && *tp == '\r') || (ch == '\r' && *tp == '\n'))
tp++; // possibly a pair.
bytesRead = (tp - s);
}
else if (!eof())
bufferLargeEnough = PR_FALSE;
else if (!mBase.eof())
bufferLargeEnough = false;
position += bytesRead;
seek(position);
mBase.seek(position);
return bufferLargeEnough;
} // nsRandomAccessInputStream::readline
//========================================================================================
// nsInputStringStream
//========================================================================================
} // nsBasicInStream::getline
//----------------------------------------------------------------------------------------
nsInputStringStream::nsInputStringStream(const char* stringToRead)
PRInt32 nsBasicInStream::read(void* s, PRInt32 n)
//----------------------------------------------------------------------------------------
{
nsISupports* stream;
if (NS_FAILED(NS_NewCharInputStream(&stream, stringToRead)))
return;
mInputStream = nsQueryInterface(stream);
mStore = nsQueryInterface(stream);
NS_RELEASE(stream);
#ifndef NS_USE_PR_STDIO
// Calling PR_Read on stdin is sure suicide on Macintosh.
if (GetStandardStream())
{
GetStandardStream()->read((char*)s, n);
return n;
}
#endif
if (!mBase.is_open() || mBase.failed())
return -1;
PRInt32 bytesRead = PR_Read(mBase.GetFileDescriptor(), s, n);
if (bytesRead < 0)
mBase.mFailed = true;
else if (bytesRead < n)
mBase.mEOF = true;
return bytesRead;
}
//----------------------------------------------------------------------------------------
nsInputStringStream::nsInputStringStream(const nsString& stringToRead)
nsBasicInStream& nsBasicInStream::operator >> (char& c)
//----------------------------------------------------------------------------------------
{
nsISupports* stream;
if (NS_FAILED(NS_NewStringInputStream(&stream, stringToRead)))
return;
mInputStream = nsQueryInterface(stream);
mStore = nsQueryInterface(stream);
NS_RELEASE(stream);
}
//========================================================================================
// nsOutputStringStream
//========================================================================================
//----------------------------------------------------------------------------------------
nsOutputStringStream::nsOutputStringStream(char*& stringToChange)
//----------------------------------------------------------------------------------------
{
nsISupports* stream;
if (NS_FAILED(NS_NewCharOutputStream(&stream, &stringToChange)))
return;
mOutputStream = nsQueryInterface(stream);
mStore = nsQueryInterface(stream);
NS_RELEASE(stream);
}
//----------------------------------------------------------------------------------------
nsOutputStringStream::nsOutputStringStream(nsString& stringToChange)
//----------------------------------------------------------------------------------------
{
nsISupports* stream;
if (NS_FAILED(NS_NewStringOutputStream(&stream, stringToChange)))
return;
mOutputStream = nsQueryInterface(stream);
mStore = nsQueryInterface(stream);
NS_RELEASE(stream);
get(c);
return *this;
}
//========================================================================================
@@ -279,32 +295,146 @@ nsOutputStringStream::nsOutputStringStream(nsString& stringToChange)
//========================================================================================
//----------------------------------------------------------------------------------------
nsInputFileStream::nsInputFileStream(
const nsFileSpec& inFile,
int nsprMode,
PRIntn accessMode)
nsInputFileStream::nsInputFileStream(istream* stream)
//----------------------------------------------------------------------------------------
#ifndef NS_USE_PR_STDIO
: nsBasicFileStream(0, kDefaultMode)
, nsBasicInStream(*this, stream)
#else
: nsBasicFileStream(PR_STDIN, kDefaultMode)
, nsBasicInStream(*this, 0)
#endif
{
}
//========================================================================================
// nsBasicOutStream
//========================================================================================
//----------------------------------------------------------------------------------------
nsBasicOutStream::nsBasicOutStream(nsBasicFileStream& inBase, ostream* stream)
//----------------------------------------------------------------------------------------
: mBase(inBase)
, mStdStream(stream)
{
}
//----------------------------------------------------------------------------------------
void nsBasicOutStream::put(char c)
//----------------------------------------------------------------------------------------
{
nsISupports* stream;
if (NS_FAILED(NS_NewIOFileStream(&stream, inFile, nsprMode, accessMode)))
write(&c, sizeof(c));
}
//----------------------------------------------------------------------------------------
PRInt32 nsBasicOutStream::write(const void* s, PRInt32 n)
//----------------------------------------------------------------------------------------
{
#ifndef NS_USE_PR_STDIO
// Calling PR_Write on stdout is sure suicide.
if (mStdStream)
{
mStdStream->write((const char*)s, n);
return n;
}
#endif
if (!mBase.mFileDesc || mBase.failed())
return -1;
PRInt32 bytesWrit = PR_Write(mBase.mFileDesc, s, n);
if (bytesWrit != n)
mBase.mFailed = true;
return bytesWrit;
}
//----------------------------------------------------------------------------------------
nsBasicOutStream& nsBasicOutStream::operator << (char c)
//----------------------------------------------------------------------------------------
{
put(c);
return *this;
}
//----------------------------------------------------------------------------------------
nsBasicOutStream& nsBasicOutStream::operator << (const char* s)
//----------------------------------------------------------------------------------------
{
write(s, strlen(s));
return *this;
}
//----------------------------------------------------------------------------------------
nsBasicOutStream& nsBasicOutStream::operator << (short val)
//----------------------------------------------------------------------------------------
{
char buf[30];
sprintf(buf, "%d", val);
return *this << buf;
}
//----------------------------------------------------------------------------------------
nsBasicOutStream& nsBasicOutStream::operator << (unsigned short val)
//----------------------------------------------------------------------------------------
{
char buf[30];
sprintf(buf, "%ud", val);
return *this << buf;
}
//----------------------------------------------------------------------------------------
nsBasicOutStream& nsBasicOutStream::operator << (long val)
//----------------------------------------------------------------------------------------
{
char buf[30];
sprintf(buf, "%ld", val);
return *this << buf;
}
//----------------------------------------------------------------------------------------
nsBasicOutStream& nsBasicOutStream::operator << (unsigned long val)
//----------------------------------------------------------------------------------------
{
char buf[30];
sprintf(buf, "%uld", val);
return *this << buf;
}
//----------------------------------------------------------------------------------------
void nsBasicOutStream::flush()
// Must precede the destructor because both are inline.
//----------------------------------------------------------------------------------------
{
#ifndef NS_USE_PR_STDIO
if (mStdStream)
{
mStdStream->flush();
return;
mFile = nsQueryInterface(stream);
mInputStream = nsQueryInterface(stream);
mStore = nsQueryInterface(stream);
mFileInputStream = nsQueryInterface(stream);
NS_RELEASE(stream);
} // nsInputFileStream::nsInputFileStream
}
#endif
if (mBase.mFileDesc == 0)
return;
PRBool itFailed = PR_Sync(mBase.mFileDesc) != PR_SUCCESS;
#ifdef XP_MAC
// On unix, it seems to fail always.
if (itFailed)
mBase.mFailed = true;
#endif
} // nsBasicOutStream::flush
//========================================================================================
// nsOutputFileStream
//========================================================================================
//----------------------------------------------------------------------------------------
void nsOutputFileStream::flush()
nsOutputFileStream::nsOutputFileStream(ostream* stream)
//----------------------------------------------------------------------------------------
#ifndef NS_USE_PR_STDIO
: nsBasicFileStream(0, kDefaultMode)
, nsBasicOutStream(*this, stream)
#else
: nsBasicFileStream(PR_STDOUT, kDefaultMode)
, nsBasicOutStream(*this, 0)
#endif
{
if (mFileOutputStream)
mFileOutputStream->Flush();
}
//========================================================================================
@@ -312,10 +442,19 @@ void nsOutputFileStream::flush()
//========================================================================================
//----------------------------------------------------------------------------------------
nsOutputStream& nsEndl(nsOutputStream& os)
nsBasicOutStream& nsEndl(nsBasicOutStream& os)
//----------------------------------------------------------------------------------------
{
os.put('\n');
os.flush();
return os;
} // nsEndl
#ifndef NS_USE_PR_STDIO
// Calling PR_Write on stdout is sure suicide on Macintosh.
ostream* stream = os.GetStandardStream();
if (stream)
{
*stream << std::endl;
return os;
}
#endif
os.put('\n');
os.flush();
return os;
}

View File

@@ -1,22 +0,0 @@
#include "nscore.h"
#include "nsCaretProperties.h"
//-----------------------------------------------------------------------------
nsCaretProperties::nsCaretProperties()
: mCaretWidth(eDefaultCaretWidth)
, mBlinkRate(eDefaulBlinkRate)
{
// in your platform-specific class, get data from the OS in your constructor
}
//-----------------------------------------------------------------------------
nsCaretProperties* NewCaretProperties()
{
return new nsCaretProperties();
}

View File

@@ -35,8 +35,6 @@ class nsISizeOfHandler;
*/
class nsIAtom : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IATOM_IID; return iid; }
/**
* Translate the unicode string into the stringbuf.
*/

View File

@@ -31,8 +31,6 @@
class nsIBaseStream : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IBASESTREAM_IID; return iid; }
/** Close the stream. */
NS_IMETHOD
Close(void) = 0;

View File

@@ -1,456 +0,0 @@
#include "nsIFileStream.h"
#include "nsFileSpec.h"
#include "prerror.h"
#ifdef XP_MAC
#include "pprio.h" // To get PR_ImportFile
#else
#include "prio.h"
#endif
#ifdef XP_MAC
#include <Errors.h>
#include <iostream>
#endif
//========================================================================================
class FileImpl
: public nsIRandomAccessStore
, public nsIFileOutputStream
, public nsIFileInputStream
, public nsIFile
//========================================================================================
{
public:
FileImpl(PRFileDesc* inDesc)
: mFileDesc(inDesc)
, mFailed(PR_FALSE)
, mEOF(PR_FALSE)
, mLength(-1)
{
NS_INIT_REFCNT();
}
FileImpl(
const nsFileSpec& inFile,
int nsprMode,
PRIntn accessMode)
: mFileDesc(nsnull)
, mFailed(PR_FALSE)
, mEOF(PR_FALSE)
{
NS_INIT_REFCNT();
Open(inFile, nsprMode, accessMode);
}
virtual ~FileImpl()
{
Close();
}
// nsISupports interface
NS_DECL_ISUPPORTS
// nsIFile interface
NS_IMETHOD Open(
const nsFileSpec& inFile,
int nsprMode,
PRIntn accessMode);
NS_IMETHOD Close();
NS_IMETHOD Seek(PRSeekWhence whence, PRInt32 offset);
NS_IMETHOD GetIsOpen(PRBool* outOpen)
{
*outOpen = (mFileDesc != nsnull);
return NS_OK;
}
NS_IMETHOD Tell(PRIntn* outWhere);
// nsIInputStream interface
NS_IMETHOD GetLength(PRUint32 *aLength)
{
NS_PRECONDITION(aLength != nsnull, "null ptr");
if (!aLength)
return NS_ERROR_NULL_POINTER;
if (mLength < 0)
return NS_FILE_RESULT(NS_ERROR_UNEXPECTED);
*aLength = mLength;
return NS_OK;
}
NS_IMETHOD Read(char* aBuf,
PRUint32 aCount,
PRUint32 *aReadCount)
{
NS_PRECONDITION(aBuf != nsnull, "null ptr");
if (!aBuf)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aReadCount != nsnull, "null ptr");
if (!aReadCount)
return NS_ERROR_NULL_POINTER;
if (!mFileDesc)
return NS_FILE_RESULT(PR_BAD_DESCRIPTOR_ERROR);
if (mFailed)
return NS_ERROR_FAILURE;
PRInt32 bytesRead = PR_Read(mFileDesc, aBuf, aCount);
if (bytesRead < 0)
{
*aReadCount = 0;
mFailed = PR_TRUE;
return NS_FILE_RESULT(PR_GetError());
}
*aReadCount = bytesRead;
return NS_OK;
}
// nsIOutputStream interface
NS_IMETHOD Write(const char* aBuf,
PRUint32 aCount,
PRUint32 *aWriteCount)
{
NS_PRECONDITION(aBuf != nsnull, "null ptr");
NS_PRECONDITION(aWriteCount != nsnull, "null ptr");
#ifdef XP_MAC
// Calling PR_Write on stdout is sure suicide.
if (mFileDesc == PR_STDOUT || mFileDesc == PR_STDERR)
{
cout.write(aBuf, aCount);
*aWriteCount = aCount;
return NS_OK;
}
#endif
if (!mFileDesc)
return NS_FILE_RESULT(PR_BAD_DESCRIPTOR_ERROR);
if (mFailed)
return NS_ERROR_FAILURE;
PRInt32 bytesWrit = PR_Write(mFileDesc, aBuf, aCount);
if (bytesWrit != (PRInt32)aCount)
{
mFailed = PR_TRUE;
*aWriteCount = 0;
return NS_FILE_RESULT(PR_GetError());
}
*aWriteCount = bytesWrit;
return NS_OK;
}
NS_IMETHOD Flush();
NS_IMETHOD GetAtEOF(PRBool* outAtEOF)
{
*outAtEOF = mEOF;
return NS_OK;
}
NS_IMETHOD SetAtEOF(PRBool inAtEOF)
{
mEOF = inAtEOF;
return NS_OK;
}
protected:
PRFileDesc* mFileDesc;
int mNSPRMode;
PRBool mFailed;
PRBool mEOF;
PRInt32 mLength;
}; // class FileImpl
#define SAY_I_IMPLEMENT(classname) \
if (aIID.Equals(classname::GetIID())) \
{ \
*aInstancePtr = (void*)((classname*)this); \
NS_ADDREF_THIS(); \
return NS_OK; \
}
NS_IMPL_RELEASE(FileImpl)
NS_IMPL_ADDREF(FileImpl)
//----------------------------------------------------------------------------------------
NS_IMETHODIMP FileImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
//----------------------------------------------------------------------------------------
{
if (!aInstancePtr)
return NS_ERROR_NULL_POINTER;
*aInstancePtr = nsnull;
SAY_I_IMPLEMENT(nsIFile)
SAY_I_IMPLEMENT(nsIRandomAccessStore)
SAY_I_IMPLEMENT(nsIOutputStream)
SAY_I_IMPLEMENT(nsIInputStream)
SAY_I_IMPLEMENT(nsIFileInputStream)
SAY_I_IMPLEMENT(nsIFileOutputStream)
// Note that we derive from two copies of nsIBaseStream (and hence
// of nsISupports), one through
// nsIOutputStream, the other through nsIInputStream. Resolve this
// by giving them a specific one
if (aIID.Equals(((nsIBaseStream*)(nsIOutputStream*)this)->GetIID()))
{
*aInstancePtr = (void*)((nsIBaseStream*)(nsIOutputStream*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(((nsISupports*)(nsIOutputStream*)this)->GetIID()))
{
*aInstancePtr = (void*)((nsISupports*)(nsIOutputStream*)this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
} // FileImpl::QueryInterface
//----------------------------------------------------------------------------------------
NS_IMETHODIMP FileImpl::Open(
const nsFileSpec& inFile,
int nsprMode,
PRIntn accessMode)
//----------------------------------------------------------------------------------------
{
if (mFileDesc)
if ((nsprMode & mNSPRMode) == nsprMode)
return NS_OK;
else
return NS_FILE_RESULT(PR_ILLEGAL_ACCESS_ERROR);
const int nspr_modes[]={
PR_WRONLY | PR_CREATE_FILE,
PR_WRONLY | PR_CREATE_FILE | PR_APPEND,
PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE,
PR_RDONLY,
PR_RDONLY | PR_APPEND,
PR_RDWR | PR_CREATE_FILE,
PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE,
// "wb",
// "ab",
// "wb",
// "rb",
// "r+b",
// "w+b",
0 };
const int* currentLegalMode = nspr_modes;
while (*currentLegalMode && nsprMode != *currentLegalMode)
++currentLegalMode;
if (!*currentLegalMode)
return NS_FILE_RESULT(PR_ILLEGAL_ACCESS_ERROR);
#ifdef XP_MAC
// Use the file spec to open the file, because one path can be common to
// several files on the Macintosh (you can have several volumes with the
// same name, see).
mFileDesc = 0;
if (inFile.Error() != noErr)
return NS_FILE_RESULT(inFile.Error());
OSErr err = noErr;
#if DEBUG
const OSType kCreator = 'CWIE';
#else
const OSType kCreator = 'MOSS';
#endif
// Resolve the alias to the original file.
nsFileSpec original = inFile;
PRBool ignoredResult;
original.ResolveAlias(ignoredResult);
const FSSpec& spec = original.operator const FSSpec&();
if (nsprMode & PR_CREATE_FILE)
err = FSpCreate(&spec, kCreator, 'TEXT', 0);
if (err == dupFNErr)
err = noErr;
if (err != noErr)
return NS_FILE_RESULT(err);
SInt8 perm;
if (nsprMode & PR_RDWR)
perm = fsRdWrPerm;
else if (nsprMode & PR_WRONLY)
perm = fsWrPerm;
else
perm = fsRdPerm;
short refnum;
err = FSpOpenDF(&spec, perm, &refnum);
if (err == noErr && (nsprMode & PR_TRUNCATE))
err = SetEOF(refnum, 0);
if (err == noErr && (nsprMode & PR_APPEND))
err = SetFPos(refnum, fsFromLEOF, 0);
if (err != noErr)
return NS_FILE_RESULT(err);
if ((mFileDesc = PR_ImportFile(refnum)) == 0)
return NS_FILE_RESULT(PR_GetError());
#else
// Platforms other than Macintosh...
// Another bug in NSPR: Mac PR_Open assumes a unix style path, but Win PR_Open assumes
// a windows path.
if ((mFileDesc = PR_Open((const char*)nsFileSpec(inFile), nsprMode, accessMode)) == 0)
return NS_FILE_RESULT(PR_GetError());
#endif
mNSPRMode = nsprMode;
mLength = PR_Available(mFileDesc);
return NS_OK;
} // FileImpl::Open
//----------------------------------------------------------------------------------------
NS_IMETHODIMP FileImpl::Seek(PRSeekWhence whence, PRInt32 offset)
//----------------------------------------------------------------------------------------
{
if (mFileDesc==PR_STDIN || mFileDesc==PR_STDOUT || mFileDesc==PR_STDERR || !mFileDesc)
return NS_FILE_RESULT(PR_BAD_DESCRIPTOR_ERROR);
mFailed = PR_FALSE; // reset on a seek.
mEOF = PR_FALSE; // reset on a seek.
PRInt32 position = PR_Seek(mFileDesc, 0, PR_SEEK_CUR);
PRInt32 available = PR_Available(mFileDesc);
PRInt32 fileSize = position + available;
PRInt32 newPosition = 0;
switch (whence)
{
case PR_SEEK_CUR: newPosition = position + offset; break;
case PR_SEEK_SET: newPosition = offset; break;
case PR_SEEK_END: newPosition = fileSize + offset; break;
}
if (newPosition < 0)
{
newPosition = 0;
mFailed = PR_TRUE;
}
if (newPosition >= fileSize) // nb: not "else if".
{
newPosition = fileSize;
mEOF = PR_TRUE;
}
if (PR_Seek(mFileDesc, newPosition, PR_SEEK_SET) < 0)
mFailed = PR_TRUE;
return NS_OK;
} // FileImpl::Seek
//----------------------------------------------------------------------------------------
NS_IMETHODIMP FileImpl::Tell(PRIntn* outWhere)
//----------------------------------------------------------------------------------------
{
if (mFileDesc==PR_STDIN || mFileDesc==PR_STDOUT || mFileDesc==PR_STDERR || !mFileDesc)
return NS_FILE_RESULT(PR_BAD_DESCRIPTOR_ERROR);
*outWhere = PR_Seek(mFileDesc, 0, PR_SEEK_CUR);
return NS_OK;
} // FileImpl::Tell
//----------------------------------------------------------------------------------------
NS_IMETHODIMP FileImpl::Close()
//----------------------------------------------------------------------------------------
{
if (mFileDesc==PR_STDIN || mFileDesc==PR_STDOUT || mFileDesc==PR_STDERR || !mFileDesc)
return NS_OK;
if (PR_Close(mFileDesc) == PR_SUCCESS)
mFileDesc = 0;
else
return NS_FILE_RESULT(PR_GetError());
return NS_OK;
} // FileImpl::close
//----------------------------------------------------------------------------------------
NS_IMETHODIMP FileImpl::Flush()
//----------------------------------------------------------------------------------------
{
#ifdef XP_MAC
if (mFileDesc == PR_STDOUT || mFileDesc == PR_STDERR)
{
cout.flush();
return NS_OK;
}
#endif
if (!mFileDesc)
return NS_FILE_RESULT(PR_BAD_DESCRIPTOR_ERROR);
PRBool itFailed = PR_Sync(mFileDesc) != PR_SUCCESS;
#ifdef XP_MAC
// On unix, it seems to fail always.
if (itFailed)
mFailed = PR_TRUE;
#endif
return NS_OK;
} // FileImpl::flush
//----------------------------------------------------------------------------------------
NS_BASE nsresult NS_NewTypicalInputFileStream(
nsISupports** aResult,
const nsFileSpec& inFile
/*Default nsprMode == PR_RDONLY*/
/*Default accessmode = 0700 (octal)*/)
// Factory method to get an nsInputStream from a file, using most common options
//----------------------------------------------------------------------------------------
{
return NS_NewIOFileStream(aResult, inFile, PR_RDONLY, 0700);
}
//----------------------------------------------------------------------------------------
NS_BASE nsresult NS_NewOutputConsoleStream(
nsISupports** aResult)
// Factory method to get an nsOutputStream to the console.
//----------------------------------------------------------------------------------------
{
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
FileImpl* stream = new FileImpl(PR_STDOUT);
if (! stream)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(stream);
*aResult = (nsISupports*)(void*)stream;
return NS_OK;
}
//----------------------------------------------------------------------------------------
NS_BASE nsresult NS_NewTypicalOutputFileStream(
nsISupports** aResult,
const nsFileSpec& inFile
/*default nsprMode= (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE)*/
/*Default accessMode= 0700 (octal)*/)
// Factory method to get an nsOutputStream to a file - most common case.
//----------------------------------------------------------------------------------------
{
return NS_NewIOFileStream(
aResult,
inFile,
(PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE),
0700);
}
//----------------------------------------------------------------------------------------
NS_BASE nsresult NS_NewIOFileStream(
nsISupports** aResult,
const nsFileSpec& inFile,
PRInt32 nsprMode /*default = (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE)*/,
PRInt32 accessMode /*Default = 0700 (octal)*/)
// Factory method to get an object that implements both nsIInputStream
// and nsIOutputStream, associated with a file.
//----------------------------------------------------------------------------------------
{
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (!aResult)
return NS_ERROR_NULL_POINTER;
FileImpl* stream = new FileImpl(inFile, nsprMode, accessMode);
if (! stream)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(stream);
*aResult = (nsISupports*)(void*)stream;
return NS_OK;
}
//----------------------------------------------------------------------------------------
NS_BASE nsresult NS_NewTypicalIOFileStream(
nsISupports** aResult,
const nsFileSpec& inFile
/*default nsprMode= (PR_RDWR | PR_CREATE_FILE)*/
/*Default accessMode= 0700 (octal)*/)
// Factory method to get an object that implements both nsIInputStream
// and nsIOutputStream, associated with a single file.
//----------------------------------------------------------------------------------------
{
return NS_NewIOFileStream(
aResult,
inFile,
(PR_RDWR | PR_CREATE_FILE),
0700);
}

View File

@@ -28,8 +28,6 @@
class nsIInputStream : public nsIBaseStream {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IINPUTSTREAM_IID; return iid; }
/** Return the number of bytes in the stream
* @param aLength out parameter to hold the length
* of the stream. if an error occurs, the length
@@ -42,6 +40,7 @@ public:
/** Read data from the stream.
* @param aErrorCode the error code if an error occurs
* @param aBuf the buffer into which the data is read
* @param aOffset the start offset of the data
* @param aCount the maximum number of bytes to read
* @param aReadCount out parameter to hold the number of
* bytes read, eof if 0. if an error occurs, the
@@ -49,7 +48,7 @@ public:
* @return error status
*/
NS_IMETHOD
Read(char* aBuf, PRUint32 aCount, PRUint32 *aReadCount) = 0;
Read(char* aBuf, PRUint32 aOffset, PRUint32 aCount, PRUint32 *aReadCount) = 0;
};
#endif /* nsInputStream_h___ */

View File

@@ -29,10 +29,9 @@
class nsIOutputStream : public nsIBaseStream {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IOUTPUTSTREAM_IID; return iid; }
/** Write data into the stream.
* @param aBuf the buffer into which the data is read
* @param aOffset the start offset of the data
* @param aCount the maximum number of bytes to read
* @param aWriteCount out parameter to hold the number of
* bytes written. if an error occurs, the writecount
@@ -40,7 +39,7 @@ public:
* @return error status
*/
NS_IMETHOD
Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount) = 0;
Write(const char* aBuf, PRUint32 aOffset, PRUint32 aCount, PRUint32 *aWriteCount) = 0;
};

View File

@@ -1,463 +0,0 @@
#include "nsIStringStream.h"
#include "nsIFileStream.h"
#include "prerror.h"
#include "nsFileSpec.h"
#include "plstr.h"
//========================================================================================
class BasicStringImpl
: public nsIOutputStream
, public nsIInputStream
, public nsIRandomAccessStore
//========================================================================================
{
public:
BasicStringImpl()
: mResult(NS_OK)
, mEOF(PR_FALSE)
, mOffset(0)
{
NS_INIT_REFCNT();
}
virtual ~BasicStringImpl()
{
}
NS_IMETHOD Seek(PRSeekWhence whence, PRInt32 offset);
NS_IMETHOD Tell(PRIntn* outWhere)
{
*outWhere = mOffset;
return NS_OK;
}
NS_IMETHOD GetAtEOF(PRBool* outAtEOF)
{
*outAtEOF = mEOF;
return NS_OK;
}
NS_IMETHOD SetAtEOF(PRBool inAtEOF)
{
mEOF = inAtEOF;
return NS_OK;
}
NS_IMETHOD GetLength(PRUint32 *aLength)
{
NS_PRECONDITION(aLength != nsnull, "null ptr");
if (!aLength)
return NS_ERROR_NULL_POINTER;
*aLength = length();
return NS_OK;
}
NS_IMETHOD Read(char* aBuf,
PRUint32 aCount,
PRUint32 *aReadCount)
{
NS_PRECONDITION(aBuf != nsnull, "null ptr");
if (!aBuf)
return NS_ERROR_NULL_POINTER;
NS_PRECONDITION(aReadCount != nsnull, "null ptr");
if (!aReadCount)
return NS_ERROR_NULL_POINTER;
if (NS_FAILED(mResult))
return mResult;
PRInt32 bytesRead = read(aBuf, aCount);
if (NS_FAILED(mResult))
{
*aReadCount = 0;
return mResult;
}
*aReadCount = bytesRead;
if (bytesRead < aCount)
SetAtEOF(PR_TRUE);
return NS_OK;
}
// nsIOutputStream interface
NS_IMETHOD Write(const char* aBuf,
PRUint32 aCount,
PRUint32 *aWriteCount)
{
NS_PRECONDITION(aBuf != nsnull, "null ptr");
NS_PRECONDITION(aWriteCount != nsnull, "null ptr");
if (NS_FAILED(mResult))
return mResult;
PRInt32 bytesWrit = write(aBuf, aCount);
if (NS_FAILED(mResult))
{
*aWriteCount = 0;
return mResult;
}
*aWriteCount = bytesWrit;
return NS_OK;
}
public:
// nsISupports interface
NS_DECL_ISUPPORTS
NS_IMETHOD Close() { return NS_OK; }
// nsIInputStream interface
NS_IMETHOD Flush() { return NS_OK; }
public:
nsresult get_result() const { return mResult; }
protected:
virtual PRInt32 length() const = 0;
virtual PRInt32 read(char* buf, PRUint32 count) = 0;
virtual PRInt32 write(const char*, PRUint32)
{
NS_ASSERTION(PR_FALSE, "Write to a const string");
mResult = NS_FILE_RESULT(PR_ILLEGAL_ACCESS_ERROR);
return -1;
}
protected:
PRUint32 mOffset;
nsresult mResult;
PRBool mEOF;
}; // class BasicStringImpl
//========================================================================================
class ConstCharImpl
: public BasicStringImpl
//========================================================================================
{
public:
ConstCharImpl(const char* inString)
: mConstString(inString)
, mLength(inString ? strlen(inString) : 0)
{
}
protected:
virtual PRInt32 length() const
{
return mLength;
}
virtual PRInt32 read(char* buf, PRUint32 aCount)
{
PRInt32 maxCount = mLength - mOffset;
if (aCount > maxCount)
aCount = maxCount;
memcpy(buf, mConstString + mOffset, aCount);
mOffset += aCount;
return aCount;
}
protected:
const char* mConstString;
size_t mLength;
}; // class ConstCharImpl
//========================================================================================
class CharImpl
: public ConstCharImpl
//========================================================================================
{
enum { kAllocQuantum = 256 };
public:
CharImpl(char** inString)
: ConstCharImpl(*inString)
, mString(*inString)
, mAllocLength(mLength + 1)
, mOriginalLength(mLength)
{
if (!mString)
{
mAllocLength += kAllocQuantum;
mString = new char[mAllocLength];
if (!mString)
{
mResult = NS_ERROR_OUT_OF_MEMORY;
return;
}
mConstString = mString;
*mString = '\0';
}
}
virtual PRInt32 write(const char* buf, PRUint32 aCount)
{
PRInt32 maxCount = mAllocLength - 1 - mOffset;
if (aCount > maxCount)
{
do {
maxCount += kAllocQuantum;
} while (aCount > maxCount);
mAllocLength = maxCount + 1 + mOffset;
char* newString = new char[mAllocLength];
if (!newString)
{
mResult = NS_ERROR_OUT_OF_MEMORY;
return 0;
}
strcpy(newString, mString);
delete [] mString;
mString = newString;
mConstString = newString;
}
memcpy(mString + mOffset, buf, aCount);
mOffset += aCount;
if (mOffset > mOriginalLength)
mString[mOffset] = 0;
return aCount;
}
protected:
char*& mString;
size_t mOriginalLength;
size_t mAllocLength;
}; // class CharImpl
//========================================================================================
class ConstStringImpl
: public ConstCharImpl
//========================================================================================
{
public:
ConstStringImpl(const nsString& inString)
: ConstCharImpl(inString.ToNewCString())
{
}
~ConstStringImpl()
{
delete [] (char*)mConstString;
}
protected:
protected:
}; // class ConstStringImpl
//========================================================================================
class StringImpl
: public ConstStringImpl
//========================================================================================
{
public:
StringImpl(nsString& inString)
: ConstStringImpl(inString)
, mString(inString)
{
}
protected:
virtual PRInt32 write(const char* buf, PRUint32 count)
{
// Clone our string as chars
char* cstring = mString.ToNewCString();
// Make a CharImpl and do the write
CharImpl chars(&cstring);
chars.Seek(PR_SEEK_SET, mOffset);
// Get the bytecount and result from the CharImpl
PRInt32 result = chars.write(buf,count);
mResult = chars.get_result();
// Set our string to match the new chars
mString = cstring;
// Set our const string also...
delete [] (char*)mConstString;
mConstString = cstring;
return result;
}
protected:
nsString& mString;
}; // class StringImpl
#define SAY_I_IMPLEMENT(classname) \
if (aIID.Equals(classname::GetIID())) \
{ \
*aInstancePtr = (void*)((classname*)this); \
NS_ADDREF_THIS(); \
return NS_OK; \
}
NS_IMPL_RELEASE(BasicStringImpl)
NS_IMPL_ADDREF(BasicStringImpl)
//----------------------------------------------------------------------------------------
NS_IMETHODIMP BasicStringImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
//----------------------------------------------------------------------------------------
{
if (!aInstancePtr)
return NS_ERROR_NULL_POINTER;
*aInstancePtr = nsnull;
SAY_I_IMPLEMENT(nsIRandomAccessStore)
SAY_I_IMPLEMENT(nsIOutputStream)
SAY_I_IMPLEMENT(nsIInputStream)
// Note that we derive from two copies of nsIBaseStream (and hence
// of nsISupports), one through
// nsIOutputStream, the other through nsIInputStream. Resolve this
// by giving them a specific one
if (aIID.Equals(((nsIBaseStream*)(nsIOutputStream*)this)->GetIID()))
{
*aInstancePtr = (void*)((nsIBaseStream*)(nsIOutputStream*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(((nsISupports*)(nsIOutputStream*)this)->GetIID()))
{
*aInstancePtr = (void*)((nsISupports*)(nsIOutputStream*)this);
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
} // StringImpl::QueryInterface
//----------------------------------------------------------------------------------------
NS_IMETHODIMP BasicStringImpl::Seek(PRSeekWhence whence, PRInt32 offset)
//----------------------------------------------------------------------------------------
{
mResult = NS_OK; // reset on a seek.
mEOF = PR_FALSE; // reset on a seek.
PRInt32 fileSize = length();
PRInt32 newPosition;
switch (whence)
{
case PR_SEEK_CUR: newPosition = mOffset + offset; break;
case PR_SEEK_SET: newPosition = offset; break;
case PR_SEEK_END: newPosition = fileSize + offset; break;
}
if (newPosition < 0)
{
newPosition = 0;
mResult = NS_FILE_RESULT(PR_FILE_SEEK_ERROR);
}
if (newPosition >= fileSize)
{
newPosition = fileSize;
mEOF = PR_TRUE;
}
mOffset = newPosition;
return NS_OK;
} // StringImpl::Seek
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewStringInputStream(
nsISupports** aStreamResult,
const nsString& aStringToRead)
// Factory method to get an nsInputStream from a string. Result will implement all the
// file stream interfaces in nsIFileStream.h
//----------------------------------------------------------------------------------------
{
NS_PRECONDITION(aStreamResult != nsnull, "null ptr");
if (! aStreamResult)
return NS_ERROR_NULL_POINTER;
ConstStringImpl* stream = new ConstStringImpl(aStringToRead);
if (! stream)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(stream);
*aStreamResult = (nsISupports*)(void*)stream;
return NS_OK;
}
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewStringOutputStream(
nsISupports** aStreamResult,
nsString& aStringToChange)
// Factory method to get an nsOutputStream from a string. Result will implement all the
// file stream interfaces in nsIFileStream.h
//----------------------------------------------------------------------------------------
{
NS_PRECONDITION(aStreamResult != nsnull, "null ptr");
if (! aStreamResult)
return NS_ERROR_NULL_POINTER;
StringImpl* stream = new StringImpl(aStringToChange);
if (! stream)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(stream);
*aStreamResult = (nsISupports*)(void*)stream;
return NS_OK;
}
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewCharInputStream(
nsISupports** aStreamResult,
const char* aStringToRead)
// Factory method to get an nsInputStream from a string. Result will implement all the
// file stream interfaces in nsIFileStream.h
//----------------------------------------------------------------------------------------
{
NS_PRECONDITION(aStreamResult != nsnull, "null ptr");
if (! aStreamResult)
return NS_ERROR_NULL_POINTER;
ConstCharImpl* stream = new ConstCharImpl(aStringToRead);
if (! stream)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(stream);
*aStreamResult = (nsISupports*)(void*)stream;
return NS_OK;
}
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewCharOutputStream(
nsISupports** aStreamResult,
char** aStringToChange)
// Factory method to get an nsOutputStream to a string. Result will implement all the
// file stream interfaces in nsIFileStream.h
//----------------------------------------------------------------------------------------
{
NS_PRECONDITION(aStreamResult != nsnull, "null ptr");
NS_PRECONDITION(aStringToChange != nsnull, "null ptr");
if (!aStreamResult || !aStringToChange)
return NS_ERROR_NULL_POINTER;
CharImpl* stream = new CharImpl(aStringToChange);
if (! stream)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(stream);
*aStreamResult = (nsISupports*)(void*)stream;
return NS_OK;
}
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewStringIOStream(
nsISupports** aStreamResult,
nsString& aStringToChange)
// Factory method to get an nsOutputStream to a string. Result will implement all the
// file stream interfaces in nsIFileStream.h
//----------------------------------------------------------------------------------------
{
return NS_NewStringOutputStream(aStreamResult, aStringToChange);
}
//----------------------------------------------------------------------------------------
extern "C" NS_BASE nsresult NS_NewCharIOStream(
nsISupports** aStreamResult,
char** aStringToChange)
// Factory method to get an nsOutputStream to a string. Result will implement all the
// file stream interfaces in nsIFileStream.h
//----------------------------------------------------------------------------------------
{
return NS_NewCharOutputStream(aStreamResult, aStringToChange);
}

View File

@@ -45,8 +45,6 @@ typedef void
*/
class nsITimer : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITIMER_IID)
/**
* Initialize a timer to fire after the given millisecond interval.
* This version takes a function to call and a closure to pass to

View File

@@ -35,9 +35,7 @@ class nsITimer;
*/
class nsITimerCallback : public nsISupports {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ITIMERCALLBACK_IID)
virtual void Notify(nsITimer *timer) = 0;
virtual void Notify(nsITimer *timer)=0;
};
#endif

View File

@@ -25,6 +25,11 @@ class nsString;
{ 0x2d97fbf0, 0x93b5, 0x11d1, \
{0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
#define NS_IB2UCONVERTER_IID \
{ 0x35e40290, 0x93b5, 0x11d1, \
{0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} }
/** Abstract unicode character input stream
* @see nsIInputStream
*/
@@ -47,6 +52,21 @@ extern NS_BASE nsresult
NS_NewStringUnicharInputStream(nsIUnicharInputStream** aInstancePtrResult,
nsString* aString);
/// Abstract interface for converting from bytes to unicode characters
class nsIB2UConverter : public nsISupports {
public:
/** aDstLen is updated to indicate how much data was translated into
* aDst; aSrcLen is updated to indicate how much data was used in
* the source buffer.
*/
NS_IMETHOD Convert(PRUnichar* aDst,
PRUint32 aDstOffset,
PRUint32& aDstLen,
const char* aSrc,
PRUint32 aSrcOffset,
PRUint32& aSrcLen) = 0;
};
/** Create a new nsUnicharInputStream that provides a converter for the
* byte input stream aStreamToWrap. If no converter can be found then
* nsnull is returned and the error code is set to
@@ -59,4 +79,13 @@ extern NS_BASE nsresult
PRInt32 aBufferSize = 0,
nsString* aCharSet = nsnull);
/** Create a new nsB2UConverter for the given character set. When given
* nsnull, the converter for iso-latin1 to unicode is provided. If no
* converter can be found, nsnull is returned.
*/
extern NS_BASE nsresult
NS_NewB2UConverter(nsIB2UConverter** aInstancePtrResult,
nsISupports* aOuter,
nsString* aCharSet = nsnull);
#endif /* nsUnicharInputStream_h___ */

View File

@@ -32,7 +32,7 @@ class nsProperties : public nsIProperties
{
public:
nsProperties();
virtual ~nsProperties();
~nsProperties();
NS_DECL_ISUPPORTS
@@ -61,19 +61,9 @@ nsProperties::nsProperties()
mTable = nsnull;
}
PR_STATIC_CALLBACK(PRIntn)
FreeHashEntries(PLHashEntry* he, PRIntn i, void* arg)
{
delete[] (PRUnichar*)he->key;
delete[] (PRUnichar*)he->value;
return HT_ENUMERATE_REMOVE;
}
nsProperties::~nsProperties()
{
if (mTable) {
// Free the PRUnicode* pointers contained in the hash table entries
PL_HashTableEnumerateEntries(mTable, FreeHashEntries, 0);
PL_HashTableDestroy(mTable);
mTable = nsnull;
}
@@ -136,8 +126,7 @@ nsProperties::Load(nsIInputStream *aIn)
}
}
mIn->Close();
NS_RELEASE(mIn);
NS_ASSERTION(!mIn, "unexpected remaining reference");
mIn = nsnull;
return NS_OK;
}
@@ -158,11 +147,7 @@ NS_IMETHODIMP
nsProperties::SetProperty(const nsString& aKey, nsString& aNewValue,
nsString& aOldValue)
{
// XXX The ToNewCString() calls allocate memory using "new" so this code
// causes a memory leak...
#if 0
cout << "will add " << aKey.ToNewCString() << "=" << aNewValue.ToNewCString() << endl;
#endif
if (!mTable) {
mTable = PL_NewHashTable(8, (PLHashFunction) HashKey,
(PLHashComparator) CompareKeys,
@@ -172,16 +157,16 @@ nsProperties::SetProperty(const nsString& aKey, nsString& aNewValue,
}
}
const PRUnichar *key = aKey.GetUnicode(); // returns internal pointer (not a copy)
PRUint32 len;
PRUnichar *key = aKey.ToNewUnicode();
PRInt32 len;
PRUint32 hashValue = nsCRT::HashValue(key, &len);
PLHashEntry **hep = PL_HashTableRawLookup(mTable, hashValue, key);
PLHashEntry *he = *hep;
if (he && aOldValue) {
// XXX fix me
}
PL_HashTableRawAdd(mTable, hep, hashValue, aKey.ToNewUnicode(),
aNewValue.ToNewUnicode());
PL_HashTableRawAdd(mTable, hep, hashValue, key,
new nsString(aNewValue.ToNewUnicode()));
return NS_OK;
}
@@ -205,13 +190,13 @@ nsProperties::Subclass(nsIProperties* aSubclass)
NS_IMETHODIMP
nsProperties::GetProperty(const nsString& aKey, nsString& aValue)
{
const PRUnichar *key = aKey;
PRUint32 len;
PRUnichar *key = aKey;
PRInt32 len;
PRUint32 hashValue = nsCRT::HashValue(key, &len);
PLHashEntry **hep = PL_HashTableRawLookup(mTable, hashValue, key);
PLHashEntry *he = *hep;
if (he) {
aValue = (const PRUnichar*)he->value;
((nsString *) he->value)->Copy(aValue);
return NS_OK;
}
@@ -262,15 +247,6 @@ nsProperties::SkipLine(PRInt32 c)
return c;
}
nsPropertiesFactory::nsPropertiesFactory()
{
NS_INIT_REFCNT();
}
nsPropertiesFactory::~nsPropertiesFactory()
{
}
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
NS_IMPL_ISUPPORTS(nsPropertiesFactory, kIFactoryIID);

View File

@@ -21,12 +21,9 @@
#include "nsIFactory.h"
class nsPropertiesFactory : public nsIFactory
class nsPropertiesFactory : nsIFactory
{
public:
nsPropertiesFactory();
virtual ~nsPropertiesFactory();
NS_DECL_ISUPPORTS
NS_IMETHOD CreateInstance(nsISupports* aOuter, REFNSIID aIID,

View File

@@ -1,369 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code,
* released March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*
* Contributors:
* Doug Turner <dougt@netscape.com>
*/
#include "nsSpecialSystemDirectory.h"
#include "nsDebug.h"
#ifdef XP_MAC
#include <Folders.h>
#include <Files.h>
#include <Memory.h>
#include <Processes.h>
#elif defined(XP_PC)
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#elif defined(XP_UNIX)
#include <unistd.h>
#include <stdlib.h>
#include <sys/param.h>
#endif
#include "plstr.h"
#if XP_PC
//----------------------------------------------------------------------------------------
static char* MakeUpperCase(char* aPath)
//----------------------------------------------------------------------------------------
{
// windows does not care about case. push to uppercase:
int length = strlen(aPath);
for (int i = 0; i < length; i++)
if (islower(aPath[i]))
aPath[i] = _toupper(aPath[i]);
return aPath;
}
#endif
//----------------------------------------------------------------------------------------
static void GetCurrentProcessDirectory(nsFileSpec& aFileSpec)
//----------------------------------------------------------------------------------------
{
#ifdef XP_PC
char buf[MAX_PATH];
if ( ::GetModuleFileName(0, buf, sizeof(buf)) ) {
// chop of the executable name by finding the rightmost backslash
char* lastSlash = PL_strrchr(buf, '\\');
if (lastSlash)
*(lastSlash + 1) = '\0';
aFileSpec = buf;
return;
}
#elif defined(XP_MAC)
// get info for the the current process to determine the directory
// its located in
OSErr err;
ProcessSerialNumber psn;
if (!(err = GetCurrentProcess(&psn)))
{
ProcessInfoRec pInfo;
FSSpec tempSpec;
// initialize ProcessInfoRec before calling
// GetProcessInformation() or die horribly.
pInfo.processName = nil;
pInfo.processAppSpec = &tempSpec;
pInfo.processInfoLength = sizeof(ProcessInfoRec);
if (!(err = GetProcessInformation(&psn, &pInfo)))
{
FSSpec appFSSpec = *(pInfo.processAppSpec);
long theDirID = appFSSpec.parID;
Str255 name;
CInfoPBRec catInfo;
catInfo.dirInfo.ioCompletion = NULL;
catInfo.dirInfo.ioNamePtr = (StringPtr)&name;
catInfo.dirInfo.ioVRefNum = appFSSpec.vRefNum;
catInfo.dirInfo.ioDrDirID = theDirID;
catInfo.dirInfo.ioFDirIndex = -1; // -1 = query dir in ioDrDirID
if (!(err = PBGetCatInfoSync(&catInfo)))
{
aFileSpec = nsFileSpec(appFSSpec.vRefNum,
catInfo.dirInfo.ioDrParID,
name);
return;
}
}
}
#elif defined(XP_UNIX)
// In the absence of a good way to get the executable directory let
// us try this for unix:
// - if MOZILLA_FIVE_HOME is defined, that is it
// - else give the current directory
char buf[MAXPATHLEN];
char *moz5 = getenv("MOZILLA_FIVE_HOME");
if (moz5)
{
aFileSpec = moz5;
return;
}
else
{
if (getcwd(buf, sizeof(buf)))
{
aFileSpec = buf;
return;
}
}
#endif
NS_ERROR("unable to get current process directory");
}
//nsSpecialSystemDirectory::nsSpecialSystemDirectory()
//: nsFileSpec(nsnull)
//{
//}
//----------------------------------------------------------------------------------------
nsSpecialSystemDirectory::nsSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory)
//----------------------------------------------------------------------------------------
: nsFileSpec(nsnull)
{
*this = aSystemSystemDirectory;
}
//----------------------------------------------------------------------------------------
nsSpecialSystemDirectory::~nsSpecialSystemDirectory()
//----------------------------------------------------------------------------------------
{
}
//----------------------------------------------------------------------------------------
void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirectory)
//----------------------------------------------------------------------------------------
{
*this = (const char*)nsnull;
switch (aSystemSystemDirectory)
{
case OS_DriveDirectory:
#ifdef XP_PC
{
char path[_MAX_PATH];
PRInt32 len = GetWindowsDirectory( path, _MAX_PATH );
if (len)
{
if ( path[1] == ':' && path[2] == '\\' )
path[3] = 0;
}
*this = MakeUpperCase(path);
}
#elif defined(XP_MAC)
{
*this = kVolumeRootFolderType;
}
#else
*this = "/";
#endif
break;
case OS_TemporaryDirectory:
#ifdef XP_PC
char path[_MAX_PATH];
if ( GetEnvironmentVariable(TEXT("TMP"), path, _MAX_PATH) == 0 )
if (GetEnvironmentVariable(TEXT("TEMP"), path, _MAX_PATH))
{
// still not set!
PRInt32 len = GetWindowsDirectory( path, _MAX_PATH );
if (len)
{
strcat( path, "temp" );
}
}
strcat( path, "\\" );
*this = MakeUpperCase(path);
#elif defined(XP_MAC)
*this = kTemporaryFolderType;
#elif defined(XP_UNIX)
*this = "/tmp/";
#endif
break;
case OS_CurrentProcessDirectory:
GetCurrentProcessDirectory(*this);
break;
#ifdef XP_MAC
case Mac_SystemDirectory:
*this = kSystemFolderType;
break;
case Mac_DesktopDirectory:
*this = kDesktopFolderType;
break;
case Mac_TrashDirectory:
*this = kTrashFolderType;
break;
case Mac_StartupDirectory:
*this = kStartupFolderType;
break;
case Mac_ShutdownDirectory:
*this = kShutdownFolderType;
break;
case Mac_AppleMenuDirectory:
*this = kAppleMenuFolderType;
break;
case Mac_ControlPanelDirectory:
*this = kControlPanelFolderType;
break;
case Mac_ExtensionDirectory:
*this = kExtensionFolderType;
break;
case Mac_FontsDirectory:
*this = kFontsFolderType;
break;
case Mac_PreferencesDirectory:
*this = kPreferencesFolderType;
break;
case Mac_DocumentsDirectory:
*this = kDocumentsFolderType;
break;
#endif
#ifdef XP_PC
case Win_SystemDirectory:
{
char path[_MAX_PATH];
PRInt32 len = GetSystemDirectory( path, _MAX_PATH );
// Need enough space to add the trailing backslash
if (len > _MAX_PATH-2)
break;
path[len] = '\\';
path[len+1] = '\0';
*this = MakeUpperCase(path);
break;
}
case Win_WindowsDirectory:
{
char path[_MAX_PATH];
PRInt32 len = GetWindowsDirectory( path, _MAX_PATH );
// Need enough space to add the trailing backslash
if (len > _MAX_PATH-2)
break;
path[len] = '\\';
path[len+1] = '\0';
*this = MakeUpperCase(path);
break;
}
#endif
#ifdef XP_UNIX
case Unix_LocalDirectory:
*this = "/usr/local/netscape/";
break;
case Unix_LibDirectory:
*this = "/usr/local/lib/netscape/";
break;
#endif
default:
break;
}
}
#ifdef XP_MAC
//----------------------------------------------------------------------------------------
nsSpecialSystemDirectory::nsSpecialSystemDirectory(OSType folderType)
//----------------------------------------------------------------------------------------
{
*this = folderType;
}
//----------------------------------------------------------------------------------------
void nsSpecialSystemDirectory::operator = (OSType folderType)
//----------------------------------------------------------------------------------------
{
CInfoPBRec cinfo;
DirInfo *dipb=(DirInfo *)&cinfo;
// Call FindFolder to fill in the vrefnum and dirid
for (int attempts = 0; attempts < 2; attempts++)
{
mError = NS_FILE_RESULT(
FindFolder(
kOnSystemDisk,
folderType,
true,
&dipb->ioVRefNum,
&dipb->ioDrDirID));
if (NS_SUCCEEDED(mError))
break;
if (attempts > 0)
return;
switch (folderType)
{
case kDocumentsFolderType:
// Find folder will find this, as long as it exists.
// The "create" parameter, however, is sadly ignored.
// How do we internationalize this?
*this = kVolumeRootFolderType;
*this += "Documents";
CreateDirectory();
break;
} // switch
} // for
StrFileName filename;
filename[0] = '\0';
dipb->ioNamePtr = (StringPtr)&filename;
dipb->ioFDirIndex = -1;
mError = NS_FILE_RESULT(PBGetCatInfoSync(&cinfo));
if (NS_SUCCEEDED(mError))
{
mError = NS_FILE_RESULT(FSMakeFSSpec(dipb->ioVRefNum, dipb->ioDrParID, filename, &mSpec));
}
}
#endif // XP_MAC

View File

@@ -27,11 +27,6 @@
#include "prdtoa.h"
#include "nsISizeOfHandler.h"
#include "nsUnicharUtilCIID.h"
#include "nsIServiceManager.h"
#include "nsICaseConversion.h"
const PRInt32 kGrowthDelta = 8;
const PRInt32 kNotFound = -1;
PRUnichar gBadChar = 0;
@@ -101,57 +96,6 @@ public:
};
static CTableConstructor gTableConstructor;
//---- XPCOM code to connect with UnicharUtil
class HandleCaseConversionShutdown2 : public nsIShutdownListener {
public :
NS_IMETHOD OnShutdown(const nsCID& cid, nsISupports* service);
HandleCaseConversionShutdown2(void) { NS_INIT_REFCNT(); }
virtual ~HandleCaseConversionShutdown2(void) {}
NS_DECL_ISUPPORTS
};
static NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID);
static NS_DEFINE_IID(kICaseConversionIID, NS_ICASECONVERSION_IID);
static nsICaseConversion * gCaseConv = NULL;
static NS_DEFINE_IID(kIShutdownListenerIID, NS_ISHUTDOWNLISTENER_IID);
NS_IMPL_ISUPPORTS(HandleCaseConversionShutdown2, kIShutdownListenerIID);
nsresult
HandleCaseConversionShutdown2::OnShutdown(const nsCID& cid, nsISupports* service)
{
if (cid.Equals(kUnicharUtilCID)) {
NS_ASSERTION(service == gCaseConv, "wrong service!");
nsrefcnt cnt = gCaseConv->Release();
gCaseConv = NULL;
}
return NS_OK;
}
static HandleCaseConversionShutdown2* gListener = NULL;
static void StartUpCaseConversion()
{
nsresult err;
if ( NULL == gListener )
{
gListener = new HandleCaseConversionShutdown2();
gListener->AddRef();
}
err = nsServiceManager::GetService(kUnicharUtilCID, kICaseConversionIID,
(nsISupports**) &gCaseConv, gListener);
}
static void CheckCaseConversion()
{
if(NULL == gCaseConv )
StartUpCaseConversion();
// NS_ASSERTION( gCaseConv != NULL , "cannot obtain UnicharUtil");
}
/***********************************************************************
IMPLEMENTATION NOTES:
@@ -350,7 +294,7 @@ const PRUnichar* nsString::GetUnicode(void) const{
return mStr;
}
nsString::operator const PRUnichar*() const{
nsString::operator PRUnichar*() const{
return mStr;
}
@@ -487,16 +431,6 @@ nsString nsString::operator+(PRUnichar aChar) {
*/
void nsString::ToLowerCase()
{
// I18N code begin
CheckCaseConversion();
if(gCaseConv) {
nsresult err = gCaseConv->ToLower(mStr, mStr, mLength);
if( NS_SUCCEEDED(err))
return;
}
// I18N code end
// somehow UnicharUtil return failed, fallback to the old ascii only code
chartype* cp = mStr;
chartype* end = cp + mLength;
while (cp < end) {
@@ -514,16 +448,6 @@ void nsString::ToLowerCase()
*/
void nsString::ToUpperCase()
{
// I18N code begin
CheckCaseConversion();
if(gCaseConv) {
nsresult err = gCaseConv->ToUpper(mStr, mStr, mLength);
if( NS_SUCCEEDED(err))
return;
}
// I18N code end
// somehow UnicharUtil return failed, fallback to the old ascii only code
chartype* cp = mStr;
chartype* end = cp + mLength;
while (cp < end) {
@@ -544,8 +468,7 @@ void nsString::ToUCS2(PRInt32 aStartOffset){
chartype* end = cp + mLength;
while (cp < end) {
unsigned char ch = (unsigned char)*cp;
if( 0x0080 == (0xFFE0 & (*cp)) ) // limit to only 0x0080 to 0x009F
*cp=gToUCS2[ch];
*cp=gToUCS2[ch];
cp++;
}
}
@@ -563,19 +486,6 @@ void nsString::ToLowerCase(nsString& aOut) const
{
aOut.EnsureCapacityFor(mLength);
aOut.mLength = mLength;
// I18N code begin
CheckCaseConversion();
if(gCaseConv) {
nsresult err = gCaseConv->ToLower(mStr, aOut.mStr, mLength);
(*(aOut.mStr+mLength)) = 0;
if( NS_SUCCEEDED(err))
return;
}
// I18N code end
// somehow UnicharUtil return failed, fallback to the old ascii only code
chartype* to = aOut.mStr;
chartype* from = mStr;
chartype* end = from + mLength;
@@ -599,18 +509,6 @@ void nsString::ToUpperCase(nsString& aOut) const
{
aOut.EnsureCapacityFor(mLength);
aOut.mLength = mLength;
// I18N code begin
CheckCaseConversion();
if(gCaseConv) {
nsresult err = gCaseConv->ToUpper(mStr, aOut.mStr, mLength);
(*(aOut.mStr+mLength)) = 0;
if( NS_SUCCEEDED(err))
return;
}
// I18N code end
// somehow UnicharUtil return failed, fallback to the old ascii only code
chartype* to = aOut.mStr;
chartype* from = mStr;
chartype* end = from + mLength;
@@ -766,11 +664,10 @@ PRInt32 nsString::ToInteger(PRInt32* aErrorCode,PRInt32 aRadix) const {
result=-result;
break;
}
else if(('+'==theChar) || (' '==theChar)) { //stop in a good state if you see this...
else if('+'==theChar) { //stop in a good state if you see this...
break;
}
else if((('x'==theChar) || ('X'==theChar)) && (16==aRadix)) {
//stop in a good state.
else if(' '==theChar){ //stop in a good state if you see this...
break;
}
else{
@@ -1367,13 +1264,12 @@ nsString& nsString::Trim(const char* aTrimSet,
nsString& nsString::CompressWhitespace( PRBool aEliminateLeading,
PRBool aEliminateTrailing)
{
Trim(" \r\n\t",aEliminateLeading,aEliminateTrailing);
PRUnichar* from = mStr;
PRUnichar* end = mStr + mLength;
PRUnichar* to = from;
Trim(" \r\n\t",aEliminateLeading,aEliminateTrailing);
//this code converts /n, /t, /r into normal space ' ';
//it also eliminates runs of whitespace...
while (from < end) {
@@ -1409,28 +1305,6 @@ nsString& nsString::StripWhitespace()
return StripChars("\r\t\n");
}
/**
* This method is used to replace all occurances of the
* given source char with the given dest char
*
* @param
* @return *this
*/
nsString& nsString::ReplaceChar(PRUnichar aSourceChar, PRUnichar aDestChar) {
PRUnichar* from = mStr;
PRUnichar* end = mStr + mLength;
while (from < end) {
PRUnichar ch = *from;
if(ch==aSourceChar) {
*from = aDestChar;
}
from++;
}
return *this;
}
/**
* Search for given character within this string.
* This method does so by using a binary search,
@@ -1700,7 +1574,7 @@ PRInt32 nsString::RFind(const char* anAsciiSet,PRBool aIgnoreCase) const{
*/
PRInt32 nsString::RFind(PRUnichar aChar,PRBool aIgnoreCase) const{
chartype uc=nsCRT::ToUpper(aChar);
for(PRInt32 offset=mLength-1;offset>=0;offset--)
for(PRInt32 offset=mLength-1;offset>0;offset--)
if(aIgnoreCase) {
if(nsCRT::ToUpper(mStr[offset])==uc)
return offset;
@@ -1807,7 +1681,6 @@ PRInt32 nsString::Compare(const PRUnichar* aString,PRBool aIgnoreCase,PRInt32 aL
PRBool nsString::operator==(const nsString &S) const {return Equals(S);}
PRBool nsString::operator==(const char *s) const {return Equals(s);}
PRBool nsString::operator==(const PRUnichar *s) const {return Equals(s);}
PRBool nsString::operator==(PRUnichar *s) const {return Equals(s);}
PRBool nsString::operator!=(const nsString &S) const {return PRBool(Compare(S)!=0);}
PRBool nsString::operator!=(const char *s) const {return PRBool(Compare(s)!=0);}
PRBool nsString::operator!=(const PRUnichar *s) const {return PRBool(Compare(s)!=0);}
@@ -2159,6 +2032,7 @@ ostream& operator<<(ostream& os,nsAutoString& aString){
}
/**
*
* @update gess 7/27/98
@@ -2178,7 +2052,7 @@ NS_BASE int fputs(const nsString& aString, FILE* out)
if(len>0)
::fwrite(cp, 1, len, out);
if (cp != buf) {
delete [] cp;
delete cp;
}
return (int) len;
}

View File

@@ -136,7 +136,7 @@ const PRUnichar* GetUnicode(void) const;
* @param
* @return
*/
operator const PRUnichar*() const;
operator PRUnichar*() const;
/**
* Retrieve unicode char at given index
@@ -499,15 +499,6 @@ nsString& Cut(PRInt32 anOffset,PRInt32 aCount);
*/
nsString& StripChars(const char* aSet);
/**
* This method is used to replace all occurances of the
* given source char with the given dest char
*
* @param
* @return *this
*/
nsString& ReplaceChar(PRUnichar aSourceChar, PRUnichar aDestChar);
/**
* This method strips whitespace throughout the string
*
@@ -657,7 +648,6 @@ virtual PRInt32 Compare(const PRUnichar *aString,PRBool aIgnoreCase=PR_FALSE,PRI
PRBool operator==(const nsString &aString) const;
PRBool operator==(const char *aString) const;
PRBool operator==(const PRUnichar* aString) const;
PRBool operator==(PRUnichar* aString) const;
/**
* These methods perform a !compare of a given string type to this
@@ -786,7 +776,6 @@ public:
virtual ~nsAutoString();
nsAutoString& operator=(const nsString& aString) {nsString::operator=(aString); return *this;}
nsAutoString& operator=(const nsAutoString& aString) {nsString::operator=(aString); return *this;}
nsAutoString& operator=(const char* aCString) {nsString::operator=(aCString); return *this;}
nsAutoString& operator=(char aChar) {nsString::operator=(aChar); return *this;}
nsAutoString& operator=(const PRUnichar* aBuffer) {nsString::operator=(aBuffer); return *this;}

View File

@@ -44,18 +44,6 @@ public:
nsTime(void) : mValue(PR_Now()) {
}
/**
* Construct the time from a string.
*/
nsTime(const char* dateStr, PRBool defaultToGMT) {
PRInt64 time;
PRStatus status = PR_ParseTimeString(dateStr, defaultToGMT, &time);
if (status == PR_SUCCESS)
mValue = time;
else
mValue = LL_ZERO;
}
/**
* Construct a time from a PRTime.
*/

View File

@@ -56,7 +56,7 @@ NS_IMPL_ISUPPORTS(UnicharBufferImpl,kUnicharBufferIID)
UnicharBufferImpl::~UnicharBufferImpl()
{
if (nsnull != mBuffer) {
delete[] mBuffer;
delete mBuffer;
mBuffer = nsnull;
}
mLength = 0;
@@ -87,7 +87,7 @@ PRBool UnicharBufferImpl::Grow(PRInt32 aNewSize)
if (0 != mLength) {
nsCRT::memcpy(newbuf, mBuffer, mLength * sizeof(PRUnichar));
}
delete[] mBuffer;
delete mBuffer;
mBuffer = newbuf;
return PR_TRUE;
}

View File

@@ -15,14 +15,9 @@
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#define NS_IMPL_IDS
#include "nsIUnicharInputStream.h"
#include "nsIByteBuffer.h"
#include "nsIUnicharBuffer.h"
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
#include "nsIUnicodeDecoder.h"
#include "nsString.h"
#include "nsCRT.h"
#include <fcntl.h>
@@ -120,36 +115,66 @@ NS_NewStringUnicharInputStream(nsIUnicharInputStream** aInstancePtrResult,
//----------------------------------------------------------------------
/**
* This function used to be public, with the NS_BASE declaration. I am
* changing it right now into a module private visibility because there are
* better and more xpcom-like ways to get a Converter.
*/
class IsoLatin1Converter : public nsIB2UConverter {
public:
IsoLatin1Converter();
nsresult NS_NewB2UConverter(nsIUnicodeDecoder** aInstancePtrResult, nsISupports* aOuter, nsString* aCharSet);
nsresult
NS_NewB2UConverter(nsIUnicodeDecoder** aInstancePtrResult,
NS_DECL_ISUPPORTS
NS_IMETHOD Convert(PRUnichar* aDst,
PRUint32 aDstOffset,
PRUint32& aDstLen,
const char* aSrc,
PRUint32 aSrcOffset,
PRUint32& aSrcLen);
};
IsoLatin1Converter::IsoLatin1Converter()
{
NS_INIT_REFCNT();
}
NS_DEFINE_IID(kIB2UConverterIID, NS_IB2UCONVERTER_IID);
NS_IMPL_ISUPPORTS(IsoLatin1Converter,kIB2UConverterIID);
nsresult IsoLatin1Converter::Convert(PRUnichar* aDst,
PRUint32 aDstOffset,
PRUint32& aDstLen,
const char* aSrc,
PRUint32 aSrcOffset,
PRUint32& aSrcLen)
{
PRUint32 amount = aSrcLen;
if (aSrcLen > aDstLen) {
amount = aDstLen;
}
const char* end = aSrc + amount;
while (aSrc < end) {
PRUint8 isoLatin1 = PRUint8(*aSrc++);
/* XXX insert table based lookup converter here */
*aDst++ = isoLatin1;
}
aDstLen = amount;
aSrcLen = amount;
return NS_OK;
}
NS_BASE nsresult
NS_NewB2UConverter(nsIB2UConverter** aInstancePtrResult,
nsISupports* aOuter,
nsString* aCharSet)
{
if (nsnull != aOuter) {
return NS_ERROR_NO_AGGREGATION;
}
// Create converter
nsresult res;
nsICharsetConverterManager * ccm;
nsAutoString defaultCharset("ISO-8859-1");
if (aCharSet == nsnull) aCharSet = &defaultCharset;
res = nsServiceManager::GetService(kCharsetConverterManagerCID,
kICharsetConverterManagerIID, (nsISupports**)&ccm);
if (NS_FAILED(res)) return res;
res = ccm->GetUnicodeDecoder(aCharSet, aInstancePtrResult);
nsServiceManager::ReleaseService(kCharsetConverterManagerCID, ccm);
return res;
// We cannot use enum to pass charset id
if ((nsnull != aCharSet) && (! aCharSet->EqualsIgnoreCase( "iso-8859-1" ))){
return NS_BASE_STREAM_NO_CONVERTER;
}
IsoLatin1Converter* it = new IsoLatin1Converter();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}
return it->QueryInterface(kIB2UConverterIID, (void**)aInstancePtrResult);
}
//----------------------------------------------------------------------
@@ -157,7 +182,7 @@ NS_NewB2UConverter(nsIUnicodeDecoder** aInstancePtrResult,
class ConverterInputStream : public nsIUnicharInputStream {
public:
ConverterInputStream(nsIInputStream* aStream,
nsIUnicodeDecoder* aConverter,
nsIB2UConverter* aConverter,
PRUint32 aBufSize);
~ConverterInputStream();
@@ -172,7 +197,7 @@ protected:
PRInt32 Fill(nsresult * aErrorCode);
nsIInputStream* mInput;
nsIUnicodeDecoder* mConverter;
nsIB2UConverter* mConverter;
nsIByteBuffer* mByteData;
PRUint32 mByteDataOffset;
nsIUnicharBuffer* mUnicharData;
@@ -181,7 +206,7 @@ protected:
};
ConverterInputStream::ConverterInputStream(nsIInputStream* aStream,
nsIUnicodeDecoder* aConverter,
nsIB2UConverter* aConverter,
PRUint32 aBufferSize)
{
NS_INIT_REFCNT();
@@ -275,10 +300,10 @@ PRInt32 ConverterInputStream::Fill(nsresult * aErrorCode)
NS_ASSERTION(remainder + nb == mByteData->GetLength(), "bad nb");
// Now convert as much of the byte buffer to unicode as possible
PRInt32 dstLen = mUnicharData->GetBufferSize();
PRInt32 srcLen = remainder + nb;
*aErrorCode = mConverter->Convert(mUnicharData->GetBuffer(), 0, &dstLen,
mByteData->GetBuffer(), 0, &srcLen);
PRUint32 dstLen = mUnicharData->GetBufferSize();
PRUint32 srcLen = remainder + nb;
*aErrorCode = mConverter->Convert(mUnicharData->GetBuffer(), 0, dstLen,
mByteData->GetBuffer(), 0, srcLen);
mUnicharDataOffset = 0;
mUnicharDataLength = dstLen;
mByteDataOffset += srcLen;
@@ -298,7 +323,7 @@ NS_NewConverterStream(nsIUnicharInputStream** aInstancePtrResult,
}
// Create converter
nsIUnicodeDecoder* converter;
nsIB2UConverter* converter;
nsresult rv = NS_NewB2UConverter(&converter, nsnull, aCharSet);
if (NS_OK != rv) {
return rv;
@@ -307,7 +332,7 @@ NS_NewConverterStream(nsIUnicharInputStream** aInstancePtrResult,
// Create converter input stream
ConverterInputStream* it =
new ConverterInputStream(aStreamToWrap, converter, aBufferSize);
NS_RELEASE(converter);
converter->Release();
if (nsnull == it) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@@ -146,12 +146,12 @@ typedef PRUcs2 PRUnichar;
/* ------------------------------------------------------------------------ */
// Casting macros for hiding C++ features from older compilers
// unix now determines this automatically
#ifndef XP_UNIX
#define HAVE_CPP_NEW_CASTS // we'll be optimistic.
#define HAS_C_PLUS_PLUS_CASTS // we'll be optimistic.
#if defined(__sgi) && !defined(__GNUC__)
#undef HAS_C_PLUS_PLUS_CASTS
#endif
#if defined(HAVE_CPP_NEW_CASTS)
#if defined(HAS_C_PLUS_PLUS_CASTS)
#define NS_STATIC_CAST(__type, __ptr) static_cast<__type>(__ptr)
#define NS_CONST_CAST(__type, __ptr) const_cast<__type>(__ptr)
#define NS_REINTERPRET_CAST(__type, __ptr) reinterpret_cast<__type>(__ptr)

View File

@@ -1,39 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nscore.h"
#include "nsCaretProperties.h"
//-----------------------------------------------------------------------------
nsCaretProperties::nsCaretProperties()
: mCaretWidth(eDefaultCaretWidth)
, mBlinkRate(eDefaulBlinkRate)
{
// in your platform-specific class, get data from the OS in your constructor
}
//-----------------------------------------------------------------------------
nsCaretProperties* NewCaretProperties()
{
return new nsCaretProperties();
}

View File

@@ -25,43 +25,9 @@
#include <dirent.h>
#include <unistd.h>
#include <stdlib.h>
#include <limits.h>
#include "nsError.h"
#if defined(IRIX) || defined(OSF1) || defined(SOLARIS) || defined(UNIXWARE) || defined(SNI) || defined(NCR) || defined(NEC) || defined(DGUX)
#include <sys/statvfs.h> /* for statvfs() */
#define STATFS statvfs
#elif defined(SCO_SV)
#define _SVID3/* for statvfs.h */
#include <sys/statvfs.h> /* for statvfs() */
#define STATFS statvfs
#elif defined(HPUX)
#include <sys/vfs.h> /* for statfs() */
#define STATFS statfs
#elif defined(LINUX)
#include <sys/vfs.h> /* for statfs() */
#define STATFS statfs
#elif defined(SUNOS4)
#include <sys/vfs.h> /* for statfs() */
extern "C" int statfs(char *, struct statfs *);
#define STATFS statfs
#else
#if defined(BSDI) || defined(NETBSD) || defined(OPENBSD) || defined(RHAPSODY) || defined(FREEBSD)
#include <sys/mount.h>/* for statfs() */
#define STATFS statfs
#else
#include <sys/statfs.h> /* for statfs() */
#define STATFS statfs
extern "C" int statfs(char *, struct statfs *);
#endif
#endif
#if defined(OSF1)
extern "C" int statvfs(const char *, struct statvfs *);
#endif
//----------------------------------------------------------------------------------------
void nsFileSpecHelpers::Canonify(char*& ioPath, PRBool inMakeDirs)
//----------------------------------------------------------------------------------------
void nsFileSpecHelpers::Canonify(char*& ioPath, bool inMakeDirs)
// Canonify, make absolute, and check whether directories exist
//----------------------------------------------------------------------------------------
{
@@ -110,99 +76,75 @@ void nsFileSpecHelpers::Canonify(char*& ioPath, PRBool inMakeDirs)
} // nsFileSpecHelpers::Canonify
//----------------------------------------------------------------------------------------
void nsFileSpec::SetLeafName(const char* inLeafName)
void nsNativeFileSpec::SetLeafName(const char* inLeafName)
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::LeafReplace(mPath, '/', inLeafName);
} // nsFileSpec::SetLeafName
} // nsNativeFileSpec::SetLeafName
//----------------------------------------------------------------------------------------
char* nsFileSpec::GetLeafName() const
char* nsNativeFileSpec::GetLeafName() const
//----------------------------------------------------------------------------------------
{
return nsFileSpecHelpers::GetLeaf(mPath, '/');
} // nsFileSpec::GetLeafName
} // nsNativeFileSpec::GetLeafName
//----------------------------------------------------------------------------------------
PRBool nsFileSpec::Exists() const
bool nsNativeFileSpec::Exists() const
//----------------------------------------------------------------------------------------
{
struct stat st;
return 0 == stat(mPath, &st);
} // nsFileSpec::Exists
} // nsNativeFileSpec::Exists
//----------------------------------------------------------------------------------------
void nsFileSpec::GetModDate(TimeStamp& outStamp) const
//----------------------------------------------------------------------------------------
{
struct stat st;
if (stat(mPath, &st) == 0)
outStamp = st.st_mtime;
else
outStamp = 0;
} // nsFileSpec::GetModDate
//----------------------------------------------------------------------------------------
PRUint32 nsFileSpec::GetFileSize() const
//----------------------------------------------------------------------------------------
{
struct stat st;
if (stat(mPath, &st) == 0)
return (PRUint32)st.st_size;
return 0;
} // nsFileSpec::GetFileSize
//----------------------------------------------------------------------------------------
PRBool nsFileSpec::IsFile() const
bool nsNativeFileSpec::IsFile() const
//----------------------------------------------------------------------------------------
{
struct stat st;
return 0 == stat(mPath, &st) && S_ISREG(st.st_mode);
} // nsFileSpec::IsFile
} // nsNativeFileSpec::IsFile
//----------------------------------------------------------------------------------------
PRBool nsFileSpec::IsDirectory() const
bool nsNativeFileSpec::IsDirectory() const
//----------------------------------------------------------------------------------------
{
struct stat st;
return 0 == stat(mPath, &st) && S_ISDIR(st.st_mode);
} // nsFileSpec::IsDirectory
} // nsNativeFileSpec::IsDirectory
//----------------------------------------------------------------------------------------
void nsFileSpec::GetParent(nsFileSpec& outSpec) const
void nsNativeFileSpec::GetParent(nsNativeFileSpec& outSpec) const
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(outSpec.mPath, mPath);
char* cp = strrchr(outSpec.mPath, '/');
if (cp)
*cp = '\0';
} // nsFileSpec::GetParent
} // nsNativeFileSpec::GetParent
//----------------------------------------------------------------------------------------
void nsFileSpec::operator += (const char* inRelativePath)
void nsNativeFileSpec::operator += (const char* inRelativePath)
//----------------------------------------------------------------------------------------
{
if (!inRelativePath || !mPath)
return;
char endChar = mPath[strlen(mPath) - 1];
if (endChar == '/')
nsFileSpecHelpers::ReallocCat(mPath, "x");
else
nsFileSpecHelpers::ReallocCat(mPath, "/x");
if (mPath[strlen(mPath) - 1] != '/')
char* newPath = nsFileSpecHelpers::ReallocCat(mPath, "/");
SetLeafName(inRelativePath);
} // nsFileSpec::operator +=
} // nsNativeFileSpec::operator +=
//----------------------------------------------------------------------------------------
void nsFileSpec::CreateDirectory(int mode)
void nsNativeFileSpec::CreateDirectory(int mode)
//----------------------------------------------------------------------------------------
{
// Note that mPath is canonical!
mkdir(mPath, mode);
} // nsFileSpec::CreateDirectory
} // nsNativeFileSpec::CreateDirectory
//----------------------------------------------------------------------------------------
void nsFileSpec::Delete(PRBool inRecursive) const
void nsNativeFileSpec::Delete(bool inRecursive)
// To check if this worked, call Exists() afterwards, see?
//----------------------------------------------------------------------------------------
{
@@ -210,9 +152,9 @@ void nsFileSpec::Delete(PRBool inRecursive) const
{
if (inRecursive)
{
for (nsDirectoryIterator i(*this); i.Exists(); i++)
for (nsDirectoryIterator i(*this); i; i++)
{
nsFileSpec& child = (nsFileSpec&)i;
nsNativeFileSpec& child = (nsNativeFileSpec&)i;
child.Delete(inRecursive);
}
}
@@ -220,178 +162,7 @@ void nsFileSpec::Delete(PRBool inRecursive) const
}
else
remove(mPath);
} // nsFileSpec::Delete
//----------------------------------------------------------------------------------------
nsresult nsFileSpec::Rename(const char* inNewName)
//----------------------------------------------------------------------------------------
{
// This function should not be used to move a file on disk.
if (strchr(inNewName, '/'))
return NS_FILE_FAILURE;
if (PR_Rename(mPath, inNewName) != 0)
{
return NS_FILE_FAILURE;
}
SetLeafName(inNewName);
return NS_OK;
} // nsFileSpec::Rename
//----------------------------------------------------------------------------------------
static int CrudeFileCopy(const char* in, const char* out)
//----------------------------------------------------------------------------------------
{
struct stat in_stat;
int stat_result = -1;
char buf [1024];
FILE *ifp, *ofp;
int rbytes, wbytes;
if (!in || !out)
return -1;
stat_result = stat (in, &in_stat);
ifp = fopen (in, "r");
if (!ifp)
{
return -1;
}
ofp = fopen (out, "w");
if (!ofp)
{
fclose (ifp);
return -1;
}
while ((rbytes = fread (buf, 1, sizeof(buf), ifp)) > 0)
{
while (rbytes > 0)
{
if ( (wbytes = fwrite (buf, 1, rbytes, ofp)) < 0 )
{
fclose (ofp);
fclose (ifp);
unlink(out);
return -1;
}
rbytes -= wbytes;
}
}
fclose (ofp);
fclose (ifp);
if (stat_result == 0)
{
chmod (out, in_stat.st_mode & 0777);
}
return 0;
} // nsFileSpec::Rename
//----------------------------------------------------------------------------------------
nsresult nsFileSpec::Copy(const nsFileSpec& inParentDirectory) const
//----------------------------------------------------------------------------------------
{
// We can only copy into a directory, and (for now) can not copy entire directories
nsresult result = NS_FILE_FAILURE;
if (inParentDirectory.IsDirectory() && (! IsDirectory() ) )
{
char *leafname = GetLeafName();
char* destPath = nsFileSpecHelpers::StringDup(
inParentDirectory.GetCString(),
strlen(inParentDirectory.GetCString()) + 1 + strlen(leafname));
strcat(destPath, "/");
strcat(destPath, leafname);
delete [] leafname;
result = NS_FILE_RESULT(CrudeFileCopy(GetCString(), destPath));
delete [] destPath;
}
return result;
} // nsFileSpec::Copy
//----------------------------------------------------------------------------------------
nsresult nsFileSpec::Move(const nsFileSpec& inNewParentDirectory) const
//----------------------------------------------------------------------------------------
{
// We can only copy into a directory, and (for now) can not copy entire directories
nsresult result = NS_FILE_FAILURE;
if (inNewParentDirectory.IsDirectory() && (! IsDirectory() ) )
{
char *leafname = GetLeafName();
char* destPath
= nsFileSpecHelpers::StringDup(
inNewParentDirectory.GetCString(),
strlen(inNewParentDirectory.GetCString()) + 1 + strlen(leafname));
strcat(destPath, "/");
strcat(destPath, leafname);
delete [] leafname;
result = NS_FILE_RESULT(CrudeFileCopy(GetCString(), destPath));
if (result == NS_OK)
{
// cast to fix const-ness
((nsFileSpec*)this)->Delete(PR_FALSE);
}
delete [] destPath;
}
return result;
}
//----------------------------------------------------------------------------------------
nsresult nsFileSpec::Execute(const char* inArgs ) const
//----------------------------------------------------------------------------------------
{
nsresult result = NS_FILE_FAILURE;
if (! IsDirectory())
{
char* fileNameWithArgs
= nsFileSpecHelpers::StringDup(mPath, strlen(mPath) + 1 + strlen(inArgs));
strcat(fileNameWithArgs, " ");
strcat(fileNameWithArgs, inArgs);
result = NS_FILE_RESULT(system(fileNameWithArgs));
delete [] fileNameWithArgs;
}
return result;
} // nsFileSpec::Execute
//----------------------------------------------------------------------------------------
PRUint32 nsFileSpec::GetDiskSpaceAvailable() const
//----------------------------------------------------------------------------------------
{
char curdir [MAXPATHLEN];
if (!mPath || !*mPath)
{
(void) getcwd(curdir, MAXPATHLEN);
if (!curdir)
return ULONG_MAX; /* hope for the best as we did in cheddar */
}
else
sprintf(curdir, "%.200s", mPath);
struct STATFS fs_buf;
if (STATFS(curdir, &fs_buf) < 0)
return ULONG_MAX; /* hope for the best as we did in cheddar */
#ifdef DEBUG_DISK_SPACE
printf("DiskSpaceAvailable: %d bytes\n",
fs_buf.f_bsize * (fs_buf.f_bavail - 1));
#endif
return fs_buf.f_bsize * (fs_buf.f_bavail - 1);
} // nsFileSpec::GetDiskSpace()
} // nsNativeFileSpec::Delete
//========================================================================================
// nsDirectoryIterator
@@ -399,12 +170,12 @@ PRUint32 nsFileSpec::GetDiskSpaceAvailable() const
//----------------------------------------------------------------------------------------
nsDirectoryIterator::nsDirectoryIterator(
const nsFileSpec& inDirectory
, int /*inIterateDirection*/)
const nsNativeFileSpec& inDirectory
, int inIterateDirection)
//----------------------------------------------------------------------------------------
: mCurrent(inDirectory)
, mExists(PR_FALSE)
, mDir(nsnull)
, mExists(false)
{
mCurrent += "sysygy"; // prepare the path for SetLeafName
mDir = opendir((const char*)nsFilePath(inDirectory));
@@ -423,7 +194,7 @@ nsDirectoryIterator::~nsDirectoryIterator()
nsDirectoryIterator& nsDirectoryIterator::operator ++ ()
//----------------------------------------------------------------------------------------
{
mExists = PR_FALSE;
mExists = false;
if (!mDir)
return *this;
char* dot = ".";
@@ -435,7 +206,7 @@ nsDirectoryIterator& nsDirectoryIterator::operator ++ ()
entry = readdir(mDir);
if (entry)
{
mExists = PR_TRUE;
mExists = true;
mCurrent.SetLeafName(entry->d_name);
}
return *this;

View File

@@ -23,13 +23,9 @@ LIBRARY_NAME=gmbase
MODULE=raptor
REQUIRES=xpcom raptor
CPPSRCS= nsTimer.cpp \
nsCaretProperties.cpp \
$(NULL)
CPP_OBJS= .\$(OBJDIR)\nsTimer.obj \
.\$(OBJDIR)\nsCaretProperties.obj \
$(NULL)
CPPSRCS=nsTimer.cpp
CPP_OBJS=.\$(OBJDIR)\nsTimer.obj
LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor
@@ -42,4 +38,3 @@ include <$(DEPTH)\config\rules.mak>
libs:: $(OBJS)
$(MAKE_INSTALL) $(OBJDIR)\nsTimer.obj ..\$(OBJDIR)
$(MAKE_INSTALL) $(OBJDIR)\nsCaretProperties.obj ..\$(OBJDIR)

View File

@@ -1,40 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nscore.h"
#include "nsCaretProperties.h"
//-----------------------------------------------------------------------------
nsCaretProperties::nsCaretProperties()
: mCaretWidth(eDefaultCaretWidth)
, mBlinkRate(eDefaulBlinkRate)
{
// in your platform-specific class, get data from the OS in your constructor
mCaretWidth = 30; // 2 pixel caret on Windows
}
//-----------------------------------------------------------------------------
nsCaretProperties* NewCaretProperties()
{
return new nsCaretProperties();
}

View File

@@ -21,36 +21,24 @@
#include <sys/stat.h>
#include <direct.h>
#include <limits.h>
#include <stdlib.h>
#include "prio.h"
#include "nsError.h"
#include "windows.h"
#ifdef UNICODE
#define CreateDirectoryW CreateDirectory
#else
#define CreateDirectoryA CreateDirectory
#endif
//----------------------------------------------------------------------------------------
void nsFileSpecHelpers::Canonify(char*& ioPath, PRBool inMakeDirs)
void nsFileSpecHelpers::Canonify(char*& ioPath, bool inMakeDirs)
// Canonify, make absolute, and check whether directories exist. This
// takes a (possibly relative) native path and converts it into a
// fully qualified native path.
//----------------------------------------------------------------------------------------
{
if (!ioPath)
return;
if (inMakeDirs)
{
const int mode = 0700;
char* unixStylePath = nsFileSpecHelpers::StringDup(ioPath);
nsFileSpecHelpers::NativeToUnix(unixStylePath);
nsFileSpecHelpers::MakeAllDirectories(unixStylePath, mode);
delete[] unixStylePath;
return;
if (inMakeDirs) {
const int mode = 0700;
char* unixStylePath = nsFileSpecHelpers::StringDup(ioPath);
nsFileSpecHelpers::NativeToUnix(unixStylePath);
nsFileSpecHelpers::MakeAllDirectories(unixStylePath, mode);
delete[] unixStylePath;
}
char buffer[_MAX_PATH];
errno = 0;
@@ -59,7 +47,7 @@ void nsFileSpecHelpers::Canonify(char*& ioPath, PRBool inMakeDirs)
NS_ASSERTION( canonicalPath[0] != '\0', "Uh oh...couldn't convert" );
if (canonicalPath[0] == '\0')
return;
return;
nsFileSpecHelpers::StringAssign(ioPath, canonicalPath);
}
@@ -137,7 +125,7 @@ void nsFileSpecHelpers::NativeToUnix(char*& ioPath)
}
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsFilePath& inPath)
nsNativeFileSpec::nsNativeFileSpec(const nsFilePath& inPath)
//----------------------------------------------------------------------------------------
: mPath(NULL)
{
@@ -145,16 +133,15 @@ nsFileSpec::nsFileSpec(const nsFilePath& inPath)
}
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const nsFilePath& inPath)
void nsNativeFileSpec::operator = (const nsFilePath& inPath)
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(mPath, (const char*)inPath);
nsFileSpecHelpers::UnixToNative(mPath);
mError = NS_OK;
} // nsFileSpec::operator =
} // nsNativeFileSpec::operator =
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const nsFileSpec& inSpec)
nsFilePath::nsFilePath(const nsNativeFileSpec& inSpec)
//----------------------------------------------------------------------------------------
: mPath(NULL)
{
@@ -162,7 +149,7 @@ nsFilePath::nsFilePath(const nsFileSpec& inSpec)
} // nsFilePath::nsFilePath
//----------------------------------------------------------------------------------------
void nsFilePath::operator = (const nsFileSpec& inSpec)
void nsFilePath::operator = (const nsNativeFileSpec& inSpec)
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(mPath, inSpec.mPath);
@@ -170,264 +157,94 @@ void nsFilePath::operator = (const nsFileSpec& inSpec)
} // nsFilePath::operator =
//----------------------------------------------------------------------------------------
void nsFileSpec::SetLeafName(const char* inLeafName)
void nsNativeFileSpec::SetLeafName(const char* inLeafName)
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::LeafReplace(mPath, '\\', inLeafName);
} // nsFileSpec::SetLeafName
} // nsNativeFileSpec::SetLeafName
//----------------------------------------------------------------------------------------
char* nsFileSpec::GetLeafName() const
char* nsNativeFileSpec::GetLeafName() const
//----------------------------------------------------------------------------------------
{
return nsFileSpecHelpers::GetLeaf(mPath, '\\');
} // nsFileSpec::GetLeafName
} // nsNativeFileSpec::GetLeafName
//----------------------------------------------------------------------------------------
PRBool nsFileSpec::Exists() const
bool nsNativeFileSpec::Exists() const
//----------------------------------------------------------------------------------------
{
struct stat st;
return 0 == stat(mPath, &st);
} // nsFileSpec::Exists
} // nsNativeFileSpec::Exists
//----------------------------------------------------------------------------------------
void nsFileSpec::GetModDate(TimeStamp& outStamp) const
//----------------------------------------------------------------------------------------
{
struct stat st;
if (stat(mPath, &st) == 0)
outStamp = st.st_mtime;
else
outStamp = 0;
} // nsFileSpec::GetModDate
//----------------------------------------------------------------------------------------
PRUint32 nsFileSpec::GetFileSize() const
//----------------------------------------------------------------------------------------
{
struct stat st;
if (stat(mPath, &st) == 0)
return (PRUint32)st.st_size;
return 0;
} // nsFileSpec::GetFileSize
//----------------------------------------------------------------------------------------
PRBool nsFileSpec::IsFile() const
bool nsNativeFileSpec::IsFile() const
//----------------------------------------------------------------------------------------
{
struct stat st;
return 0 == stat(mPath, &st) && (_S_IFREG & st.st_mode);
} // nsFileSpec::IsFile
} // nsNativeFileSpec::IsFile
//----------------------------------------------------------------------------------------
PRBool nsFileSpec::IsDirectory() const
bool nsNativeFileSpec::IsDirectory() const
//----------------------------------------------------------------------------------------
{
struct stat st;
return 0 == stat(mPath, &st) && (_S_IFDIR & st.st_mode);
} // nsFileSpec::IsDirectory
} // nsNativeFileSpec::IsDirectory
//----------------------------------------------------------------------------------------
void nsFileSpec::GetParent(nsFileSpec& outSpec) const
void nsNativeFileSpec::GetParent(nsNativeFileSpec& outSpec) const
//----------------------------------------------------------------------------------------
{
nsFileSpecHelpers::StringAssign(outSpec.mPath, mPath);
char* cp = strrchr(outSpec.mPath, '\\');
if (cp)
*cp = '\0';
} // nsFileSpec::GetParent
} // nsNativeFileSpec::GetParent
//----------------------------------------------------------------------------------------
void nsFileSpec::operator += (const char* inRelativePath)
void nsNativeFileSpec::operator += (const char* inRelativePath)
//----------------------------------------------------------------------------------------
{
if (!inRelativePath || !mPath)
return;
if (mPath[strlen(mPath) - 1] == '\\')
nsFileSpecHelpers::ReallocCat(mPath, "x");
else
nsFileSpecHelpers::ReallocCat(mPath, "\\x");
// If it's a (unix) relative path, make it native
char* dosPath = nsFileSpecHelpers::StringDup(inRelativePath);
nsFileSpecHelpers::UnixToNative(dosPath);
SetLeafName(dosPath);
delete [] dosPath;
} // nsFileSpec::operator +=
if (mPath[strlen(mPath) - 1] != '\\')
char* newPath = nsFileSpecHelpers::ReallocCat(mPath, "\\");
SetLeafName(inRelativePath);
} // nsNativeFileSpec::operator +=
//----------------------------------------------------------------------------------------
void nsFileSpec::CreateDirectory(int /*mode*/)
void nsNativeFileSpec::CreateDirectory(int /*mode*/)
//----------------------------------------------------------------------------------------
{
// Note that mPath is canonical!
mkdir(mPath);
} // nsFileSpec::CreateDirectory
} // nsNativeFileSpec::CreateDirectory
//----------------------------------------------------------------------------------------
void nsFileSpec::Delete(PRBool inRecursive) const
void nsNativeFileSpec::Delete(bool inRecursive)
//----------------------------------------------------------------------------------------
{
if (IsDirectory())
if (IsDirectory())
{
if (inRecursive)
{
for (nsDirectoryIterator i(*this); i.Exists(); i++)
{
nsFileSpec& child = (nsFileSpec&)i;
child.Delete(inRecursive);
}
for (nsDirectoryIterator i(*this); i; i++)
{
nsNativeFileSpec& child = (nsNativeFileSpec&)i;
child.Delete(inRecursive);
}
}
rmdir(mPath);
}
else
{
remove(mPath);
remove(mPath);
}
} // nsFileSpec::Delete
//----------------------------------------------------------------------------------------
nsresult nsFileSpec::Rename(const char* inNewName)
//----------------------------------------------------------------------------------------
{
// This function should not be used to move a file on disk.
if (strchr(inNewName, '/'))
return NS_FILE_FAILURE;
if (PR_Rename(*this, inNewName) != NS_OK)
{
return NS_FILE_FAILURE;
}
SetLeafName(inNewName);
return NS_OK;
} // nsFileSpec::Rename
//----------------------------------------------------------------------------------------
nsresult nsFileSpec::Copy(const nsFileSpec& inParentDirectory) const
//----------------------------------------------------------------------------------------
{
// We can only copy into a directory, and (for now) can not copy entire directories
if (inParentDirectory.IsDirectory() && (! IsDirectory() ) )
{
char *leafname = GetLeafName();
char* destPath = nsFileSpecHelpers::StringDup(inParentDirectory, ( strlen(inParentDirectory) + 1 + strlen(leafname) ) );
strcat(destPath, "\\");
strcat(destPath, leafname);
delete [] leafname;
// CopyFile returns non-zero if succeeds
int copyOK = CopyFile(*this, destPath, true);
delete[] destPath;
if (copyOK)
{
return NS_OK;
}
}
return NS_FILE_FAILURE;
} // nsFileSpec::Copy
//----------------------------------------------------------------------------------------
nsresult nsFileSpec::Move(const nsFileSpec& nsNewParentDirectory) const
//----------------------------------------------------------------------------------------
{
// We can only copy into a directory, and (for now) can not copy entire directories
if (nsNewParentDirectory.IsDirectory() && (! IsDirectory() ) )
{
char *leafname = GetLeafName();
char *destPath = nsFileSpecHelpers::StringDup(nsNewParentDirectory, ( strlen(nsNewParentDirectory) + 1 + strlen(leafname) ));
strcat(destPath, "\\");
strcat(destPath, leafname);
delete [] leafname;
// MoveFile returns non-zero if succeeds
int copyOK = MoveFile(*this, destPath);
delete [] destPath;
if (copyOK)
{
return NS_OK;
}
}
return NS_FILE_FAILURE;
} // nsFileSpec::Move
//----------------------------------------------------------------------------------------
nsresult nsFileSpec::Execute(const char* inArgs ) const
//----------------------------------------------------------------------------------------
{
if (! IsDirectory())
{
char* fileNameWithArgs = NULL;
fileNameWithArgs = nsFileSpecHelpers::StringDup(mPath, ( strlen(mPath) + 1 + strlen(inArgs) ) );
strcat(fileNameWithArgs, " ");
strcat(fileNameWithArgs, inArgs);
int execResult = WinExec( fileNameWithArgs, SW_NORMAL );
delete [] fileNameWithArgs;
if (execResult > 31)
{
return NS_OK;
}
}
return NS_FILE_FAILURE;
} // nsFileSpec::Execute
//----------------------------------------------------------------------------------------
PRUint32 nsFileSpec::GetDiskSpaceAvailable() const
//----------------------------------------------------------------------------------------
{
char aDrive[_MAX_DRIVE + 2];
_splitpath( mPath, aDrive, NULL, NULL, NULL);
if (aDrive[0] == '\0')
{
// The back end is always trying to pass us paths that look
// like /c|/netscape/mail. See if we've got one of them
if (strlen(mPath) > 2 && mPath[0] == '/' && mPath[2] == '|')
{
aDrive[0] = mPath[1];
aDrive[1] = ':';
aDrive[2] = '\0';
}
else
{
// Return bogus large number and hope for the best
return ULONG_MAX;
}
}
strcat(aDrive, "\\");
DWORD dwSectorsPerCluster = 0;
DWORD dwBytesPerSector = 0;
DWORD dwFreeClusters = 0;
DWORD dwTotalClusters = 0;
if (!GetDiskFreeSpace(aDrive,
&dwSectorsPerCluster,
&dwBytesPerSector,
&dwFreeClusters,
&dwTotalClusters))
{
return ULONG_MAX; // Return bogus large number and hope for the best
}
// We can now figure free disk space.
return dwFreeClusters * dwSectorsPerCluster * dwBytesPerSector;
} // nsFileSpec::GetDiskSpaceAvailable()
} // nsNativeFileSpec::Delete
//========================================================================================
// nsDirectoryIterator
@@ -435,12 +252,12 @@ PRUint32 nsFileSpec::GetDiskSpaceAvailable() const
//----------------------------------------------------------------------------------------
nsDirectoryIterator::nsDirectoryIterator(
const nsFileSpec& inDirectory
const nsNativeFileSpec& inDirectory
, int inIterateDirection)
//----------------------------------------------------------------------------------------
: mCurrent(inDirectory)
, mDir(nsnull)
, mExists(PR_FALSE)
, mExists(false)
{
mDir = PR_OpenDir(inDirectory);
mCurrent += "dummy";
@@ -459,13 +276,13 @@ nsDirectoryIterator::~nsDirectoryIterator()
nsDirectoryIterator& nsDirectoryIterator::operator ++ ()
//----------------------------------------------------------------------------------------
{
mExists = PR_FALSE;
mExists = false;
if (!mDir)
return *this;
PRDirEntry* entry = PR_ReadDir(mDir, PR_SKIP_BOTH); // Ignore '.' && '..'
PRDirEntry* entry = PR_ReadDir(mDir, PR_SKIP_BOTH); // Ignore '.' && '..'
if (entry)
{
mExists = PR_TRUE;
mExists = true;
mCurrent.SetLeafName(entry->name);
}
return *this;

File diff suppressed because it is too large Load Diff

View File

@@ -21,33 +21,13 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
CPPSRCS = TestAtoms.cpp TestCRT.cpp CvtURL.cpp FilesTest.cpp PropertiesTest.cpp TestAutoLock.cpp
REQUIRES = xpcom netlib
CPPSRCS = TestAtoms.cpp TestCRT.cpp FilesTest.cpp
LIBS = \
-lnetlib \
-labouturl \
-lfileurl \
-lremoturl \
-lgophurl \
-lnetcnvts \
-lsockstuburl \
-lftpurl \
-lmimetype \
-lpwcac \
-lhttpurl \
-lnetwork \
-lnetutil \
-lnetcache \
-lgmbase$(MOZ_TOOLKIT) \
$(TK_LIBS) \
-lpref \
-lsecfree \
-l$(MOZ_LIB_JS_PREFIX)js \
-lxp \
-lraptorbase \
-lxpcom \
-lreg \
$(ZLIB_LIBS) \
$(NSPR_LIBS) \
$(NULL)

View File

@@ -24,50 +24,30 @@
#include "nsIProperties.h"
#include "nsIServiceManager.h"
#include "nsIURL.h"
#include "nsIComponentManager.h"
#include "nsRepository.h"
#ifdef XP_PC
#include "plevent.h"
#endif
#define TEST_URL "resource:/res/test.properties"
#ifdef XP_PC
#define NETLIB_DLL "netlib.dll"
#define RAPTORBASE_DLL "raptorbase.dll"
#define XPCOM_DLL "xpcom32.dll"
#else
#ifdef XP_MAC
#define NETLIB_DLL "NETLIB_DLL"
#define RAPTORBASE_DLL "base.shlb"
#define XPCOM_DLL "XPCOM_DLL"
#else
#define NETLIB_DLL "libnetlib.so"
#define RAPTORBASE_DLL "libraptorbase.so"
#define XPCOM_DLL "libxpcom32.so"
#endif
#endif
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
static NS_DEFINE_IID(kIPropertiesIID, NS_IPROPERTIES_IID);
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
#ifdef XP_MAC // have not build this on PC and UNIX yet so make it #ifdef XP_MAC
extern "C" void NS_SetupRegistry();
#endif
int
main(int argc, char *argv[])
{
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL,
nsRepository::RegisterFactory(kNetServiceCID, NETLIB_DLL, PR_FALSE,
PR_FALSE);
nsRepository::RegisterFactory(kEventQueueServiceCID, XPCOM_DLL,
PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL,
PR_FALSE, PR_FALSE);
#ifdef XP_MAC // have not build this on PC and UNIX yet so make it #ifdef XP_MAC
NS_SetupRegistry();
#endif
nsresult ret;
nsIEventQueueService* pEventQueueService = nsnull;
ret = nsServiceManager::GetService(kEventQueueServiceCID,
@@ -102,7 +82,7 @@ main(int argc, char *argv[])
return 1;
}
nsIProperties *props = nsnull;
ret = nsComponentManager::CreateInstance(kPropertiesCID, NULL,
ret = nsRepository::CreateInstance(kPropertiesCID, NULL,
kIPropertiesIID, (void**) &props);
if (NS_FAILED(ret)) {
printf("create nsIProperties failed\n");

View File

@@ -1,72 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
Some tests for nsAutoLock.
*/
#include "nsAutoLock.h"
#include "prthread.h"
PRLock* gLock;
int gCount;
static void run(void* arg)
{
for (int i = 0; i < 1000000; ++i) {
nsAutoLock guard(gLock);
++gCount;
PR_ASSERT(gCount == 1);
--gCount;
}
}
int main(int argc, char** argv)
{
gLock = PR_NewLock();
gCount = 0;
// This shouldn't compile
//nsAutoLock* l1 = new nsAutoLock(theLock);
//delete l1;
// Create a block-scoped lock. This should compile.
{
nsAutoLock l2(gLock);
}
// Fork a thread to access the shared variable in a tight loop
PRThread* t1 =
PR_CreateThread(PR_SYSTEM_THREAD,
run,
nsnull,
PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD,
PR_JOINABLE_THREAD,
0);
// ...and now do the same thing ourselves
run(nsnull);
// Wait for the background thread to finish, if necessary.
PR_JoinThread(t1);
return 0;
}

View File

@@ -24,7 +24,6 @@ PROG2 = .\$(OBJDIR)\CvtURL.exe
PROG3 = .\$(OBJDIR)\TestCRT.exe
PROG4 = .\$(OBJDIR)\FilesTest.exe
PROG5 = .\$(OBJDIR)\PropertiesTest.exe
PROG6 = .\$(OBJDIR)\TestAutoLock.exe
RESFILE = timer.res
PROGRAMS = $(PROG0) $(PROG1) \
!ifdef MODULAR_NETLIB
@@ -33,7 +32,6 @@ PROGRAMS = $(PROG0) $(PROG1) \
$(PROG5) \
!endif
$(PROG4) \
$(PROG6) \
$(NULL)
LINCS=-I..\src -I$(PUBLIC)\xpcom -I$(PUBLIC)\netlib -I$(PUBLIC)\raptor
@@ -45,7 +43,7 @@ LLIBS= \
$(DIST)\lib\netlib.lib \
!endif
$(LIBNSPR) \
$(DIST)\lib\plc3.lib \
$(DIST)\lib\libplc21.lib \
!if "$(MOZ_BITS)"=="32" && defined(MOZ_DEBUG) && defined(GLOWCODE)
$(GLOWDIR)\glowcode.lib \
!endif
@@ -63,7 +61,6 @@ install:: $(PROGRAMS)
$(MAKE_INSTALL) test.properties $(DIST)\bin\res
!endif
$(MAKE_INSTALL) $(PROG4) $(DIST)\bin
$(MAKE_INSTALL) $(PROG6) $(DIST)\bin
clobber::
rm -f $(DIST)\bin\TimerTest.exe
@@ -75,7 +72,6 @@ clobber::
rm -f $(DIST)\bin\res\test.properties
!endif
rm -f $(DIST)\bin\FilesTest.exe
rm -f $(DIST)\bin\TestAutoLock.exe
# Move this into config/obj.inc when it's allowed
.cpp{.\$(OBJDIR)\}.exe:
@@ -106,7 +102,3 @@ $(PROG3): $(OBJDIR) TestCRT.cpp
$(PROG5): $(OBJDIR) PropertiesTest.cpp
!endif
$(PROG6): $(OBJDIR) TestAutoLock.cpp

View File

@@ -1,104 +0,0 @@
dnl The contents of this file are subject to the Netscape Public License
dnl Version 1.0 (the "NPL"); you may not use this file except in
dnl compliance with the NPL. You may obtain a copy of the NPL at
dnl http://www.mozilla.org/NPL/
dnl
dnl Software distributed under the NPL is distributed on an "AS IS" basis,
dnl WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
dnl for the specific language governing rights and limitations under the
dnl NPL.
dnl
dnl The Initial Developer of this code under the NPL is Netscape
dnl Communications Corporation. Portions created by Netscape are
dnl Copyright (C) 1999 Netscape Communications Corporation. All Rights
dnl Reserved.
dnl
dnl altoptions.m4 - An alternative way of specifying command-line options.
dnl These macros are needed to support a menu-based configurator.
dnl This file also includes the macro, AM_READ_MYCONFIG, for reading
dnl the 'myconfig.m4' file.
dnl Send comments, improvements, bugs to Steve Lamm (slamm@netscape.com).
dnl MOZ_ARG_ENABLE_BOOL( NAME, HELP, IF-YES [, IF-NO [, ELSE]])
dnl MOZ_ARG_DISABLE_BOOL( NAME, HELP, IF-NO [, IF-YES [, ELSE]])
dnl MOZ_ARG_ENABLE_STRING( NAME, HELP, IF-SET [, ELSE])
dnl MOZ_ARG_ENABLE_BOOL_OR_STRING( NAME, HELP, IF-YES, IF-NO, IF-SET[, ELSE]]])
dnl MOZ_ARG_WITH_BOOL( NAME, HELP, IF-YES [, IF-NO [, ELSE])
dnl MOZ_ARG_WITHOUT_BOOL( NAME, HELP, IF-NO [, IF-YES [, ELSE])
dnl MOZ_ARG_WITH_STRING( NAME, HELP, IF-SET [, ELSE])
dnl MOZ_ARG_HEADER(Comment)
dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file
dnl MOZ_TWO_STRING_TEST(NAME, STR1, IF-STR1, STR2, IF-STR2 [, ELSE])
AC_DEFUN(MOZ_TWO_STRING_TEST,
[if test "$enableval" = "[$2]"; then
ifelse([$3], , :, [$3])
elif test "$enableval" = "[$4]"; then
ifelse([$5], , :, [$5])
else
ifelse([$6], ,
[AC_MSG_ERROR([Option, [$1], does not take an argument ($enableval).])],
[$6])
fi])
dnl MOZ_ARG_ENABLE_BOOL(NAME, HELP, IF-YES [, IF-NO [, ELSE]])
AC_DEFUN(MOZ_ARG_ENABLE_BOOL,
[AC_ARG_ENABLE([$1], [$2],
[MOZ_TWO_STRING_TEST([$1], yes, [$3], no, [$4])],
[$5])])
dnl MOZ_ARG_DISABLE_BOOL(NAME, HELP, IF-NO [, IF-YES [, ELSE]])
AC_DEFUN(MOZ_ARG_DISABLE_BOOL,
[AC_ARG_ENABLE([$1], [$2],
[MOZ_TWO_STRING_TEST([$1], no, [$3], yes, [$4])],
[$5])])
dnl MOZ_ARG_ENABLE_STRING(NAME, HELP, IF-SET [, ELSE])
AC_DEFUN(MOZ_ARG_ENABLE_STRING,
[AC_ARG_ENABLE([$1], [$2], [$3], [$4])])
dnl MOZ_ARG_ENABLE_BOOL_OR_STRING(NAME, HELP, IF-YES, IF-NO, IF-SET[, ELSE]]])
AC_DEFUN(MOZ_ARG_ENABLE_BOOL_OR_STRING,
[ifelse([$5], ,
[errprint([Option, $1, needs an "IF-SET" argument.
])
m4exit(1)],
[AC_ARG_ENABLE([$1], [$2],
[MOZ_TWO_STRING_TEST([$1], yes, [$3], no, [$4], [$5])],
[$6])])])
dnl MOZ_ARG_WITH_BOOL(NAME, HELP, IF-YES [, IF-NO [, ELSE])
AC_DEFUN(MOZ_ARG_WITH_BOOL,
[AC_ARG_WITH([$1], [$2],
[MOZ_TWO_STRING_TEST([$1], yes, [$3], no, [$4])],
[$5])])
dnl MOZ_ARG_WITHOUT_BOOL(NAME, HELP, IF-NO [, IF-YES [, ELSE])
AC_DEFUN(MOZ_ARG_WITHOUT_BOOL,
[AC_ARG_WITH([$1], [$2],
[MOZ_TWO_STRING_TEST([$1], no, [$3], yes, [$4])],
[$5])])
dnl MOZ_ARG_WITH_STRING(NAME, HELP, IF-SET [, ELSE])
AC_DEFUN(MOZ_ARG_WITH_STRING,
[AC_ARG_WITH([$1], [$2], [$3], [$4])])
dnl MOZ_ARG_HEADER(Comment)
dnl This is used by webconfig to group options
define(MOZ_ARG_HEADER, [# $1])
dnl MOZ_READ_MYCONFIG() - Read in 'myconfig.sh' file
AC_DEFUN(MOZ_READ_MOZCONFIG,
[AC_REQUIRE([AC_INIT_BINSH])dnl
# Read in 'mozconfig.sh' script to set the initial options.
# See the load-mozconfig.sh script for more details.
TOPSRCDIR=`dirname [$]0`
PATH="$TOPSRCDIR/build/autoconf:$PATH"
. load-mozconfig.sh])
dnl This gets inserted at the top of the configure script
MOZ_READ_MOZCONFIG

View File

@@ -1,46 +0,0 @@
#!/bin/sh
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
# clean-config.sh - Removes all files generated by mozilla configure.
# Only removes files from the topsrcdir. To clean up an objdir,
# simply remove the directory and start over.
#
# Usage:
# 1. cd <topsrcdir>
# 2. build/autoconf/clean-config.sh
#
# Send comments, improvements, bugs to slamm@netscape.com
topsrcdir=`cd \`dirname $0\`/../..; pwd`
if [ ! -f configure.in ]; then
echo "clean-config.sh only cleans the source tree. To run," 2>&1
echo " cd $topsrcdir; build/autoconf/clean-config.sh" 2>&1
echo " (To clean a separate objdir, simple remove the directory.)" 2>&1
exit 1
fi
MOZ_EDITOR=1 MOZ_MAILNEWS=1 . allmakefiles.sh
rm -fr $MAKEFILES \
config-defs.h \
config.cache \
config.log \
config.status \
$NULL
echo "Removed all files generated by configure." 2>&1

View File

@@ -749,9 +749,6 @@ EOF
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit 0 ;;
*:QNX:*:*)
echo i386-pc-qnx`${UNAME_VERSION} | cut -c1-1`
exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2

View File

@@ -143,10 +143,6 @@ case $os in
-psos*)
os=-psos
;;
-qnx*)
basic_machine=i386-pc
os=-qnx`uname -v | cut -c1-1`
;;
esac
# Decode aliases for certain CPU-COMPANY combinations.
@@ -509,10 +505,6 @@ case $basic_machine in
ps2)
basic_machine=i386-ibm
;;
*qnx*)
basic_machine=i386-pc
os=-qnx`uname -v | cut -c1-1`
;;
rm[46]00)
basic_machine=mips-siemens
;;
@@ -783,8 +775,6 @@ case $os in
-xenix)
os=-xenix
;;
-qnx*)
;;
-none)
;;
*)

View File

@@ -1,41 +0,0 @@
#! /bin/sh
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
# Reserved.
#
# find-mozconfig.sh - Loads options from mozconfig.sh onto configure's
# command-line. The mozconfig.sh file is searched for in the
# order:
# if $MOZCONFIG is set, use that.
# Otherwise, use $TOPSRCDIR/mozconfig.sh
# Otherwise, use $HOME/.mozconfig.sh
#
topsrcdir=`cd \`dirname $0\`/../..; pwd`
for _config in $MOZCONFIG \
$MOZ_MYCONFIG \
$topsrcdir/mozconfig \
$topsrcdir/mozconfig.sh \
$topsrcdir/myconfig.sh \
$HOME/.mozconfig \
$HOME/.mozconfig.sh \
$HOME/.mozmyconfig.sh
do
if test -f $_config; then
echo $_config;
exit 0
fi
done

View File

@@ -1,97 +0,0 @@
# sh
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
# Reserved.
#
# load-mozconfig.sh - Loads options from mozconfig.sh onto configure's
# command-line. See find-mozconfig.sh for how the config file is
# found
#
# The options from mozconfig.sh are inserted into the command-line
# before the real command-line options. This way the real options
# will override any mozconfig.sh options.
#
# mozconfig.sh is a shell script. To add an option to configure's
# command-line use the pre-defined function, ac_add_options,
#
# ac_add_options <configure-option> [<configure-option> ... ]
#
# For example,
#
# ac_add_options --with-pthreads --enable-debug
#
# ac_add_options can be called multiple times in mozconfig.sh.
# Each call adds more options to configure's command-line.
#
# Send comments, improvements, bugs to Steve Lamm (slamm@netscape.com).
ac_add_options() {
for _opt
do
# Escape shell characters, space, tab, dollar, quote, backslash.
_opt=`echo $_opt | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g;s/@\([^@]*\)@/\$\1/g;'`
_opt=`echo $_opt | sed -e 's/@\([^@]*\)@/\$(\1)/g'`
# Avoid adding duplicates
case "$ac_options" in
*"$_opt"* ) ;;
* ) mozconfig_ac_options="$mozconfig_ac_options $_opt" ;;
esac
done
}
mk_add_options() {
# These options are for client.mk
# configure can safely ignore them.
:
}
ac_echo_options() {
echo "Adding options from $MOZCONFIG:"
eval "set -- $mozconfig_ac_options"
for _opt
do
echo " $_opt"
done
}
#
# Define load the options
#
ac_options=
mozconfig_ac_options=
# Save the real command-line options
for _opt
do
# Escape shell characters, space, tab, dollar, quote, backslash.
_opt=`echo $_opt | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g;'`
ac_options="$ac_options \"$_opt\""
done
# Call find-mozconfig.sh
# In params: $MOZCONFIG $HOME (old:$MOZ_MYCONFIG)
MOZCONFIG=`$TOPSRCDIR/build/autoconf/find-mozconfig.sh`
if [ "$MOZCONFIG" ]; then
. $MOZCONFIG
ac_echo_options 1>&2
fi
eval "set -- $mozconfig_ac_options $ac_options"

View File

@@ -1,93 +0,0 @@
#!/bin/sh
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
#
# This script will match a dir with a set of dirs.
#
# Usage: match-dir.sh match [dir1 dir2 ... dirn]
#
# Send comments, improvements, bugs to ramiro@netscape.com
#
# Make sure a Makefile.in exists
#if [ $# -lt 1 ]
#then
# echo
# echo "Usage: `basename $0` match [dir1 dir2 ... dirn]"
# echo
#
# exit 1
#fi
# Make sure a Makefile.in exists
if [ ! -f Makefile.in ]
then
echo
echo "There ain't no 'Makefile.in' over here: $pwd, dude."
echo
exit 1
fi
# Use DEPTH in the Makefile.in to determine the depth
depth=`grep -w DEPTH Makefile.in | grep -e "\.\." | awk -F"=" '{ print $2; }'`
# Determine the depth count
n=`echo $depth | tr '/' ' ' | wc -w`
# Determine the path (strip anything before the mozilla/ root)
path=`pwd | awk -v count=$n -F"/" '\
{ for(i=NF-count+0; i <= NF ; i++) \
{ \
if (i!=NF) \
{ printf "%s/", $i } \
else \
{ printf "%s", $i } \
} \
}'`
match=$path
for i in $*
do
# echo "Looking for $match in $i"
echo $i | grep -q -x $match
if [ $? -eq 0 ]
then
echo "1"
exit 0
fi
# echo "Looking for $i in $match"
echo $match | grep -q $i
if [ $? -eq 0 ]
then
echo "1"
exit 0
fi
done
echo "0"
exit 0

View File

@@ -1,81 +0,0 @@
#! /bin/sh
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
# Reserved.
#
# mozconfig2defs.sh - Translates mozconfig.sh into options for client.mk.
# Prints defines to stdout.
#
# See load-mozconfig.sh for more details
#
# Send comments, improvements, bugs to Steve Lamm (slamm@netscape.com).
print_header() {
echo "# gmake"
echo "# This file is automatically generated for client.mk."
echo "# Do not edit. Edit $MOZCONFIG instead."
echo
}
ac_add_options() {
for _opt
do
# Escape shell characters, space, tab, dollar, quote, backslash,
# and substitute '@<word>@' with '$(<word)'.
_opt=`echo $_opt | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g; s/@\([^@]*\)@/\$(\1)/g;'`
case "$_opt" in
--with-nspr=* ) echo MOZ_WITH_NSPR=`expr $_opt : ".*=\(.*\)"` ;;
--with-pthreads* ) echo MOZ_WITH_PTHREADS=1 ;;
--*-* ) echo "# $_opt is not used by client.mk" ;;
esac
done
}
mk_add_options() {
for _opt
do
# Escape shell characters, space, tab, dollar, quote, backslash,
# and substitute '@<word>@' with '$(<word)'.
echo $_opt | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g; s/@\([^@]*\)@/\$(\1)/g;'
done
}
#
# main
#
out_file=$1
tmp_file="$out_file-tmp$$"
trap "rm -f $tmp_file; exit 1" 1 2 15
# find-mozconfig.sh
# In params: $MOZCONFIG $HOME ($MOZ_MYCONFIG)
MOZCONFIG=`\`dirname $0\`/find-mozconfig.sh`
if [ "$MOZCONFIG" ]
then
print_header >$tmp_file
. $MOZCONFIG >> $tmp_file
if cmp -s $tmp_file $out_file; then
rm $tmp_file
else
mv -f $tmp_file $out_file
fi
else
echo "# This file is automatically generated for client.mk." > $out_file
fi

View File

@@ -1,63 +0,0 @@
#! /bin/sh
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1999 Netscape Communications Corporation. All Rights
# Reserved.
#
# mozconfig2defs.sh - Translates mozconfig.sh into options for client.mk.
# Prints defines to stdout.
#
# See load-mozconfig.sh for more details
#
# Send comments, improvements, bugs to Steve Lamm (slamm@netscape.com).
ac_add_options() {
for _opt
do
# Escape shell characters, space, tab, dollar, quote, backslash,
# and substitute '@<word>@' with '$(<word)'.
_opt=`echo $_opt | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g;'`
case "$_opt" in
--*-*= ) query_string="$query_string$_opt&" ;;
--*-* ) query_string="$query_string$_opt=yes&" ;;
esac
done
}
mk_add_options() {
for _opt
do
# Escape shell characters, space, tab, dollar, quote, backslash,
# and substitute '@<word>@' with '$(<word)'.
query_string=$query_string`echo "$_opt&" | sed -e 's/\([\ \ \$\"\\]\)/\\\\\1/g;'`
done
}
#
# main
#
# find-mozconfig.sh
# In params: $MOZCONFIG $HOME ($MOZ_MYCONFIG)
MOZCONFIG=`\`dirname $0\`/find-mozconfig.sh`
if [ "$MOZCONFIG" ]
then
query_string="?"
. $MOZCONFIG
echo `expr "$query_string" : "\(.*\)."`
fi

View File

@@ -1,59 +0,0 @@
#!/bin/sh
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
#
# This script will print the depth path for a mozilla directory based
# on the info in Makefile.in
#
# Its a hack. Its brute force. Its horrible.
# It dont use Artificial Intelligence. It dont use Virtual Reality.
# Its not perl. Its not python. But it works.
#
# Usage: print-depth-path.sh
#
# Send comments, improvements, bugs to ramiro@netscape.com
#
# Make sure a Makefile.in exists
if [ ! -f Makefile.in ]
then
echo
echo "There ain't no 'Makefile.in' over here: $pwd, dude."
echo
exit
fi
# Use DEPTH in the Makefile.in to determine the depth
depth=`grep -w DEPTH Makefile.in | grep -e "\.\." | awk -F"=" '{ print $2; }'`
# Determine the depth count
n=`echo $depth | tr '/' ' ' | wc -w`
# Determine the path (strip anything before the mozilla/ root)
path=`pwd | awk -v count=$n -F"/" '\
{ for(i=NF-count+0; i <= NF ; i++) \
{ \
if (i!=NF) \
{ printf "%s/", $i } \
else \
{ printf "%s", $i } \
} \
}'`
echo $path

View File

@@ -29,30 +29,47 @@
# Send comments, improvements, bugs to ramiro@netscape.com
#
# Make sure a Makefile exists
if [ ! -f Makefile ]
# Make sure a Makefile.in exists
if [ ! -f Makefile.in ]
then
echo
echo "There ain't no 'Makefile' over here: $pwd"
echo "There ain't no 'Makefile.in' over here: $pwd"
echo
exit
fi
# Use DEPTH in the Makefile to determine the depth
depth=`egrep '^DEPTH[ ]*=[ ]*\.' Makefile | awk -F= '{ print $2; }'`
# Use DEPTH in the Makefile.in to determine the depth
depth=`grep -w DEPTH Makefile.in | grep -e "\.\." | awk -F"=" '{ print $2; }'`
# Get the full path to the Makefile
makefile=`pwd`/Makefile
# Determine the depth count
n=`echo $depth | tr '/' ' ' | wc -w`
# Determine the path (strip anything before the mozilla/ root)
path=`pwd | awk -v count=$n -F"/" '\
{ for(i=NF-count+1; i <= NF ; i++) \
{ \
if (i!=NF) \
{ printf "%s/", $i } \
else \
{ printf "%s", $i } \
} \
}'`
dir=$path
# Add a slash only to dirs where depth >= mozilla_root
if [ $n -gt 0 ]
then
dir=${dir}"/"
fi
back=`pwd`
makefile=${dir}"Makefile"
# 'cd' to the root of the tree
echo depth=$depth
cd $depth
# Strip the tree root off the Makefile's path
root_path=`pwd`
makefile=`expr $makefile : $root_path'/\(.*\)'`
# Make sure config.status exists
if [ -f config.status ]
then
@@ -62,3 +79,5 @@ else
echo "There ain't no 'config.status' over here: $pwd"
echo
fi
cd $back

View File

@@ -88,9 +88,6 @@ sub BuildMozilla()
BuildProject(":mozilla:lib:mac:NSStdLib:NSStdLib.mcp", "NSStdLib$D.shlb");
MakeAlias(":mozilla:lib:mac:NSStdLib:NSStdLib$D.shlb", "$dist_dir");
BuildProject(":mozilla:modules:libreg:macbuild:libreg.mcp", "libreg$D.shlb");
MakeAlias(":mozilla:modules:libreg:macbuild:libreg$D.shlb", "$dist_dir");
BuildProject(":mozilla:xpcom:macbuild:xpcomPPC.mcp", "xpcom$D.shlb");
MakeAlias(":mozilla:xpcom:macbuild:xpcom$D.shlb", "$dist_dir");

View File

@@ -65,20 +65,12 @@
#pragma peephole off
#pragma optimize_for_size off
#else
#pragma traceback on /* leave on until the final release, so MacsBug logs are interpretable */
#pragma traceback off
#pragma global_optimizer on
#pragma optimization_level 4
#pragma scheduling 603
#pragma scheduling 604
#pragma peephole on
#pragma optimize_for_size on
#pragma opt_strength_reduction on
#pragma opt_propagation on
#pragma opt_loop_invariants on
#pragma opt_lifetimes on
#pragma opt_dead_code on
#pragma opt_dead_assignments on
#pragma opt_common_subs on
#endif
#else /* ...generating 68k */

View File

@@ -30,7 +30,6 @@ B<Moz> comprises the routines needed to slap CodeWarrior around, force it to bui
package Moz;
require Exporter;
use Mac::Events;
@ISA = qw(Exporter);
@EXPORT = qw(BuildProject BuildProjectClean OpenErrorLog MakeAlias StopForErrors DontStopForErrors InstallFromManifest SetBuildNumber SetAgentString SetTimeBomb Delay);
@@ -246,7 +245,7 @@ sub build_project($$$)
$had_errors = CodeWarriorLib::build_project(
$project_path, $target_name, $recent_errors_file, $clean_build
);
WaitNextEvent();
# $had_errors =
#MacPerl::DoAppleScript(<<END_OF_APPLESCRIPT);
@@ -254,7 +253,7 @@ sub build_project($$$)
#END_OF_APPLESCRIPT
# Append any errors to the globally accumulated log file
# if ( $had_errors ) # Removed this test, because we want warnings, too. -- jrm
if ( $had_errors )
{
log_recent_errors($project_path);
}
@@ -343,8 +342,6 @@ sub InstallFromManifest($;$)
chop($dest_dir) if $dest_dir =~ m/:$/;
#Mac::Events->import();
WaitNextEvent();
print "Doing manifest on \"$manifest_file\"\n" unless $QUIET;
my $read = maniread(full_path_to($manifest_file));

View File

@@ -175,31 +175,8 @@ sub BuildDist()
InstallFromManifest(":mozilla:nsprpub:lib:libc:include:MANIFEST", "$distdirectory:nspr:");
InstallFromManifest(":mozilla:nsprpub:lib:msgc:include:MANIFEST", "$distdirectory:nspr:");
#INTL
#UCONV
InstallFromManifest(":mozilla:intl:uconv:public:MANIFEST", "$distdirectory:uconv:");
InstallFromManifest(":mozilla:intl:uconv:ucvlatin:MANIFEST", "$distdirectory:uconv:");
InstallFromManifest(":mozilla:intl:uconv:ucvja:MANIFEST", "$distdirectory:uconv:");
InstallFromManifest(":mozilla:intl:uconv:ucvja2:MANIFEST", "$distdirectory:uconv:");
# InstallFromManifest(":mozilla:intl:uconv:ucvtw:MANIFEST", "$distdirectory:uconv:");
# InstallFromManifest(":mozilla:intl:uconv:ucvtw2:MANIFEST", "$distdirectory:uconv:");
# InstallFromManifest(":mozilla:intl:uconv:ucvcn:MANIFEST", "$distdirectory:uconv:");
# InstallFromManifest(":mozilla:intl:uconv:ucvko:MANIFEST", "$distdirectory:uconv:");
# InstallFromManifest(":mozilla:intl:uconv:ucvth:MANIFEST", "$distdirectory:uconv:");
# InstallFromManifest(":mozilla:intl:uconv:ucvvt:MANIFEST", "$distdirectory:uconv:");
#UNICHARUTIL
InstallFromManifest(":mozilla:intl:unicharutil:public:MANIFEST", "$distdirectory:unicharutil");
#LOCALE
InstallFromManifest(":mozilla:intl:locale:public:MANIFEST", "$distdirectory:locale:");
#LWBRK
InstallFromManifest(":mozilla:intl:lwbrk:public:MANIFEST", "$distdirectory:lwbrk:");
#STRRES
InstallFromManifest(":mozilla:intl:strres:public:MANIFEST", "$distdirectory:strres:");
#JPEG
InstallFromManifest(":mozilla:jpeg:MANIFEST", "$distdirectory:jpeg:");
@@ -209,8 +186,7 @@ sub BuildDist()
#XPCOM
InstallFromManifest(":mozilla:xpcom:public:MANIFEST", "$distdirectory:xpcom:");
InstallFromManifest(":mozilla:xpcom:src:MANIFEST", "$distdirectory:xpcom:");
#ZLIB
InstallFromManifest(":mozilla:modules:zlib:src:MANIFEST", "$distdirectory:zlib:");
@@ -230,10 +206,6 @@ sub BuildDist()
#LIVECONNECT
InstallFromManifest(":mozilla:js:src:liveconnect:MANIFEST", "$distdirectory:liveconnect:");
#CAPS
InstallFromManifest(":mozilla:caps:public:MANIFEST", "$distdirectory:caps:");
InstallFromManifest(":mozilla:caps:include:MANIFEST", "$distdirectory:caps:");
#SECURITY_freenav
InstallFromManifest(":mozilla:modules:security:freenav:MANIFEST", "$distdirectory:security:");
@@ -253,9 +225,6 @@ sub BuildDist()
InstallFromManifest(":mozilla:modules:oji:src:MANIFEST", "$distdirectory:oji:");
InstallFromManifest(":mozilla:modules:oji:public:MANIFEST", "$distdirectory:oji:");
#DBM
InstallFromManifest(":mozilla:dbm:include:MANIFEST", "$distdirectory:dbm:");
#LAYERS (IS THIS STILL NEEDED)
InstallFromManifest(":mozilla:lib:liblayer:include:MANIFEST", "$distdirectory:layers:");
@@ -291,17 +260,15 @@ sub BuildDist()
#WEBSHELL
InstallFromManifest(":mozilla:webshell:public:MANIFEST", "$distdirectory:webshell:");
InstallFromManifest(":mozilla:webshell:tests:viewer:public:MANIFEST", "$distdirectory:webshell:");
InstallFromManifest(":mozilla:webshell:tests:viewer:public:MANIFEST", "$distdirectory:webshell:");
#LAYOUT
InstallFromManifest(":mozilla:layout:build:MANIFEST", "$distdirectory:layout:");
InstallFromManifest(":mozilla:layout:base:public:MANIFEST", "$distdirectory:layout:");
InstallFromManifest(":mozilla:layout:html:document:src:MANIFEST", "$distdirectory:layout:");
InstallFromManifest(":mozilla:layout:html:style:public:MANIFEST", "$distdirectory:layout:");
InstallFromManifest(":mozilla:layout:html:style:src:MANIFEST", "$distdirectory:layout:");
InstallFromManifest(":mozilla:layout:html:base:src:MANIFEST", "$distdirectory:layout:");
InstallFromManifest(":mozilla:layout:html:forms:public:MANIFEST", "$distdirectory:layout:");
InstallFromManifest(":mozilla:layout:html:table:public:MANIFEST", "$distdirectory:layout:");
InstallFromManifest(":mozilla:layout:base:src:MANIFEST", "$distdirectory:layout:");
InstallFromManifest(":mozilla:layout:events:public:MANIFEST", "$distdirectory:layout:");
InstallFromManifest(":mozilla:layout:events:src:MANIFEST", "$distdirectory:layout:");
@@ -321,24 +288,18 @@ sub BuildDist()
#DOM
InstallFromManifest(":mozilla:dom:public:MANIFEST", "$distdirectory:dom:");
InstallFromManifest(":mozilla:dom:public:base:MANIFEST", "$distdirectory:dom:");
InstallFromManifest(":mozilla:dom:public:coreDom:MANIFEST", "$distdirectory:dom:");
InstallFromManifest(":mozilla:dom:public:coreEvents:MANIFEST", "$distdirectory:dom:");
InstallFromManifest(":mozilla:dom:public:events:MANIFEST", "$distdirectory:dom:");
InstallFromManifest(":mozilla:dom:public:html:MANIFEST", "$distdirectory:dom:");
InstallFromManifest(":mozilla:dom:public:css:MANIFEST", "$distdirectory:dom:");
InstallFromManifest(":mozilla:dom:src:jsurl:MANIFEST", "$distdirectory:dom:");
InstallFromManifest(":mozilla:dom:src:base:MANIFEST", "$distdirectory:dom:");
#HTMLPARSER
InstallFromManifest(":mozilla:htmlparser:src:MANIFEST", "$distdirectory:htmlparser:");
#EXPAT
InstallFromManifest(":mozilla:expat:xmlparse:MANIFEST", "$distdirectory:expat:");
#RDF
InstallFromManifest(":mozilla:rdf:base:public:MANIFEST", "$distdirectory:rdf:");
InstallFromManifest(":mozilla:rdf:util:public:MANIFEST", "$distdirectory:rdf:");
InstallFromManifest(":mozilla:rdf:content:public:MANIFEST", "$distdirectory:rdf:");
InstallFromManifest(":mozilla:rdf:datasource:public:MANIFEST", "$distdirectory:rdf:");
InstallFromManifest(":mozilla:rdf:build:MANIFEST", "$distdirectory:rdf:");
@@ -353,23 +314,19 @@ sub BuildDist()
#FULL CIRCLE
if ($main::MOZ_FULLCIRCLE)
{
InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory");
InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory");
if ($main::DEBUG)
{
#InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory:viewer_debug:");
#InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory:viewer_debug:");
}
else
{
#InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory:viewer:");
InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory");
#InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory:viewer:");
InstallFromManifest(":ns:fullsoft:public:MANIFEST", "$distdirectory");
}
}
# XPAPPS
InstallFromManifest(":mozilla:xpfe:AppCores:public:MANIFEST", "$distdirectory:xpfe:");
InstallFromManifest(":mozilla:xpfe:appshell:public:MANIFEST", "$distdirectory:xpfe:");
#// To get out defines in all the project, dummy alias NGLayoutConfigInclude.h into MacConfigInclude.h
MakeAlias(":mozilla:config:mac:NGLayoutConfigInclude.h", ":mozilla:dist:config:MacConfigInclude.h");
}
@@ -388,8 +345,10 @@ sub BuildStubs()
#//
#// Clean projects
#//
BuildProjectClean(":mozilla:lib:mac:MacMemoryAllocator:MemAllocator.mcp", "Stubs");
BuildProjectClean(":mozilla:lib:mac:NSStdLib:NSStdLib.mcp", "Stubs");
BuildProjectClean(":mozilla:lib:mac:NSRuntime:NSRuntime.mcp", "Stubs");
# BuildProjectClean(":mozilla:cmd:macfe:projects:client:Client.mcp", "Stubs");
}
@@ -401,14 +360,13 @@ sub BuildStubs()
#// are the same.
#//--------------------------------------------------------------------------------------------------
sub BuildOneProject($$$$$$)
sub BuildOneProject($$$$$)
{
my ($project_path, $target_name, $toc_file, $alias_shlb, $alias_xSYM, $component) = @_;
my ($project_path, $target_name, $toc_file, $alias_shlb, $alias_xSYM) = @_;
# $D becomes a suffix to target names for selecting either the debug or non-debug target of a project
my($D) = $main::DEBUG ? "Debug" : "";
my($dist_dir) = _getDistDirectory();
my($component_dir) = $component ? "Components:" : "";
my($project_dir) = $project_path;
$project_dir =~ s/:[^:]+$/:/; # chop off leaf name
@@ -426,7 +384,7 @@ sub BuildOneProject($$$$$$)
BuildProject($project_path, $target_name);
$alias_shlb ? MakeAlias("$project_dir$target_name", "$dist_dir$component_dir") : 0;
$alias_shlb ? MakeAlias("$project_dir$target_name", "$dist_dir") : 0;
$alias_xSYM ? MakeAlias("$project_dir$target_name.xSYM", "$dist_dir") : 0;
}
@@ -461,77 +419,49 @@ sub BuildCommonProjects()
BuildProject(":mozilla:cmd:macfe:projects:interfaceLib:Interface.mcp", "MacOS Interfaces");
}
BuildOneProject(":mozilla:lib:mac:NSRuntime:NSRuntime.mcp", "NSRuntime$D.shlb", "", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:lib:mac:NSRuntime:NSRuntime.mcp", "NSRuntime$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
BuildProject(":mozilla:lib:mac:MoreFiles:build:MoreFilesPPC.mcp", "MoreFiles.o");
BuildOneProject(":mozilla:lib:mac:MoreFiles:build:MoreFilesPPC.mcp", "MoreFiles$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
BuildProject(":mozilla:lib:mac:MacMemoryAllocator:MemAllocator.mcp", "MemAllocator$D.o");
BuildOneProject(":mozilla:nsprpub:macbuild:NSPR20PPC.mcp", "NSPR20$D.shlb", "NSPR20.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:lib:mac:NSStdLib:NSStdLib.mcp", "NSStdLib$D.shlb", "", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:lib:mac:MacMemoryAllocator:MemAllocator.mcp", "MemAllocator$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:nsprpub:macbuild:NSPR20PPC.mcp", "NSPR20$D.shlb", "NSPR20.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:jpeg:macbuild:JPEG.mcp", "JPEG$D.shlb", "JPEG.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:lib:mac:NSStdLib:NSStdLib.mcp", "NSStdLib$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:modules:libreg:macbuild:libreg.mcp", "libreg$D.shlb", "", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:jpeg:macbuild:JPEG.mcp", "JPEG$D.shlb", "JPEG.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:xpcom:macbuild:xpcomPPC.mcp", "xpcom$D.shlb", "xpcom.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:xpcom:macbuild:xpcomPPC.mcp", "xpcom$D.shlb", "xpcom.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:js:macbuild:JavaScript.mcp", "JavaScript$D.shlb", "JavaScript.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:js:macbuild:LiveConnect.mcp", "LiveConnect$D.shlb", "", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:js:macbuild:JavaScript.mcp", "JavaScript$D.shlb", "JavaScript.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:modules:zlib:macbuild:zlib.mcp", "zlib$D.shlb", "zlib.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:caps:macbuild:Caps.mcp", "Caps$D.shlb", "", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:modules:oji:macbuild:oji.mcp", "oji$D.shlb", "", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:js:macbuild:LiveConnect.mcp", "LiveConnect$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:modules:libpref:macbuild:libpref.mcp", "libpref$D.shlb", "libpref.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:modules:zlib:macbuild:zlib.mcp", "zlib$D.shlb", "zlib.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:base:macbuild:base.mcp", "base$D.shlb", "base.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:modules:libpref:macbuild:libpref.mcp", "libpref$D.shlb", "libpref.toc", 1, $main::ALIAS_SYM_FILES);
# International projects
BuildOneProject(":mozilla:intl:uconv:macbuild:uconv.mcp", "uconv$D.shlb", "uconv.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:base:macbuild:base.mcp", "base$D.shlb", "base.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:intl:uconv:macbuild:ucvlatin.mcp", "ucvlatin$D.shlb", "uconvlatin.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:intl:uconv:macbuild:uconv.mcp", "uconv$D.shlb", "uconv.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:intl:uconv:macbuild:ucvja.mcp", "ucvja$D.shlb", "ucvja.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:intl:uconv:macbuild:ucvlatin.mcp", "ucvlatin$D.shlb", "uconvlatin.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:intl:uconv:macbuild:ucvja2.mcp", "ucvja2$D.shlb", "ucvja2.toc", 1, $main::ALIAS_SYM_FILES, 1);
#// Have not enable yet... place holder
# BuildOneProject(":mozilla:intl:uconv:macbuild:ucvtw.mcp", "ucvtw$D.shlb", "ucvtw.toc", 1, $main::ALIAS_SYM_FILES, 0);
# BuildOneProject(":mozilla:intl:uconv:macbuild:ucvtw2.mcp", "ucvtw2$D.shlb", "ucvtw2.toc", 1, $main::ALIAS_SYM_FILES, 0);
# BuildOneProject(":mozilla:intl:uconv:macbuild:ucvcn.mcp", "ucvcn$D.shlb", "ucvcn.toc", 1, $main::ALIAS_SYM_FILES, 0);
# BuildOneProject(":mozilla:intl:uconv:macbuild:ucvko.mcp", "ucvko$D.shlb", "ucvko.toc", 1, $main::ALIAS_SYM_FILES, 0);
# BuildOneProject(":mozilla:intl:uconv:macbuild:ucvvt.mcp", "ucvvt$D.shlb", "ucvvt.toc", 1, $main::ALIAS_SYM_FILES, 0);
# BuildOneProject(":mozilla:intl:uconv:macbuild:ucvth.mcp", "ucvth$D.shlb", "ucvth.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:intl:unicharutil:macbuild:unicharutil.mcp", "unicharutil$D.shlb", "unicharutil.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:intl:uconv:macbuild:ucvja.mcp", "ucvja$D.shlb", "ucvja.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:intl:locale:macbuild:locale.mcp", "nslocale$D.shlb", "nslocale.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:intl:lwbrk:macbuild:lwbrk.mcp", "lwbrk$D.shlb", "lwbrk.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:intl:strres:macbuild:strres.mcp", "strres$D.shlb", "strres.toc", 1, $main::ALIAS_SYM_FILES, 0);
#// removing powerplant - long live powerplant
# BuildOneProject(":mozilla:lib:mac:PowerPlant:PowerPlant.mcp", "PowerPlant$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:modules:libutil:macbuild:libutil.mcp", "libutil$D.shlb", "libutil.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:modules:libutil:macbuild:libutil.mcp", "libutil$D.shlb", "libutil.toc", 1, $main::ALIAS_SYM_FILES);
ReconcileProject(":mozilla:modules:libimg:macbuild:png.mcp", ":mozilla:modules:libimg:macbuild:png.toc");
BuildProject(":mozilla:modules:libimg:macbuild:png.mcp", "png$D.o");
BuildOneProject(":mozilla:modules:libimg:macbuild:libimg.mcp", "libimg$D.shlb", "libimg.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:modules:libimg:macbuild:libimg.mcp", "libimg$D.shlb", "libimg.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:network:macbuild:network.mcp", "NetworkModular$D.shlb", "network.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:network:macbuild:network.mcp", "NetworkModular$D.shlb", "network.toc", 1, $main::ALIAS_SYM_FILES);
#// XXX moved this TEMPORARILY to layout while we sort out a dependency
# BuildOneProject(":mozilla:rdf:macbuild:rdf.mcp", "rdf$D.shlb", "rdf.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:rdf:macbuild:rdf.mcp", "rdf$D.shlb", "rdf.toc", 1, $main::ALIAS_SYM_FILES);
}
@@ -578,7 +508,6 @@ sub MakeResouceAliases()
#//
my($resource_dir) = "$dist_dir" . "res:";
MakeAlias(":mozilla:layout:html:document:src:ua.css", "$resource_dir");
MakeAlias(":mozilla:webshell:tests:viewer:resources:viewer.properties", "$resource_dir");
my($html_dir) = "$resource_dir" . "html:";
MakeAlias(":mozilla:layout:html:base:src:broken-image.gif", "$html_dir");
@@ -602,9 +531,6 @@ sub MakeResouceAliases()
# NOTE: this will change as we move the toolbar/appshell chrome files to a real place
BuildFolderResourceAliases(":mozilla:xpfe:browser:src:", "$samples_dir");
BuildFolderResourceAliases(":mozilla:xpfe:AppCores:xul:", "$samples_dir");
BuildFolderResourceAliases(":mozilla:xpfe:AppCores:xul:resources:", "$toolbar_dir");
MakeAlias(":mozilla:xpfe:AppCores:xul:resources:throbbingN.gif", "$throbber_dir");
}
@@ -645,26 +571,22 @@ sub BuildLayoutProjects()
#// Build Layout projects
#//
BuildOneProject(":mozilla:htmlparser:macbuild:htmlparser.mcp", "htmlparser$D.shlb", "htmlparser.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:htmlparser:macbuild:htmlparser.mcp", "htmlparser$D.shlb", "htmlparser.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:dom:macbuild:dom.mcp", "dom$D.shlb", "dom.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:dom:macbuild:dom.mcp", "dom$D.shlb", "dom.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:gfx:macbuild:gfx.mcp", "gfx$D.shlb", "gfx.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:gfx:macbuild:gfx.mcp", "gfx$D.shlb", "gfx.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:modules:plugin:macbuild:plugin.mcp", "plugin$D.shlb", "plugin.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:modules:plugin:macbuild:plugin.mcp", "plugin$D.shlb", "plugin.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:layout:macbuild:layout.mcp", "layout$D.shlb", "layout.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:layout:macbuild:layout.mcp", "layout$D.shlb", "layout.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:view:macbuild:view.mcp", "view$D.shlb", "view.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:view:macbuild:view.mcp", "view$D.shlb", "view.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:widget:macbuild:widget.mcp", "widget$D.shlb", "widget.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:widget:macbuild:widget.mcp", "widget$D.shlb", "widget.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:webshell:macbuild:webshell.mcp", "webshell$D.shlb", "webshell.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:webshell:embed:mac:RaptorShell.mcp", "RaptorShell$D.shlb", "RaptorShell.toc", 1, $main::ALIAS_SYM_FILES, 0);
#// XXX this is here because of a very TEMPORARY dependency
BuildOneProject(":mozilla:rdf:macbuild:rdf.mcp", "rdf$D.shlb", "rdf.toc", 1, $main::ALIAS_SYM_FILES, 1);
BuildOneProject(":mozilla:webshell:macbuild:webshell.mcp", "webshell$D.shlb", "webshell.toc", 1, $main::ALIAS_SYM_FILES);
}
@@ -681,11 +603,11 @@ sub BuildEditorProjects()
my($D) = $main::DEBUG ? "Debug" : "";
my($dist_dir) = _getDistDirectory();
BuildOneProject(":mozilla:editor:txmgr:macbuild:txmgr.mcp", "EditorTxmgr$D.shlb", "txmgr.toc", 1, $main::ALIAS_SYM_FILES, 1);
BuildOneProject(":mozilla:editor:txmgr:macbuild:txmgr.mcp", "EditorTxmgr$D.shlb", "txmgr.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:editor:guimgr:macbuild:EditorGuiManager.mcp", "EditorGuiManager$D.shlb", "EditorGuiManager.toc", 1, $main::ALIAS_SYM_FILES, 1);
BuildOneProject(":mozilla:editor:guimgr:macbuild:EditorGuiManager.mcp", "EditorGuiManager$D.shlb", "EditorGuiManager.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:editor:macbuild:editor.mcp", "EditorCore$D.shlb", "EditorCore.toc", 1, $main::ALIAS_SYM_FILES, 1);
BuildOneProject(":mozilla:editor:macbuild:editor.mcp", "EditorCore$D.shlb", "EditorCore.toc", 1, $main::ALIAS_SYM_FILES);
}
@@ -703,9 +625,10 @@ sub BuildViewerProjects()
my($D) = $main::DEBUG ? "Debug" : "";
my($dist_dir) = _getDistDirectory();
BuildOneProject(":mozilla:webshell:tests:viewer:mac:viewer.mcp", "viewer$D", "viewer.toc", 0, 0, 0);
BuildOneProject(":mozilla:webshell:tests:viewer:mac:viewer.mcp", "viewer$D", "viewer.toc", 0, 0);
# BuildOneProject(":mozilla:xpfe:macbuild:xpfeviewer.mcp", "xpfeviewer$D.shlb", "xpfeviewer.toc", 0, 0);
# BuildOneProject(":mozilla:xpfe:macbuild:xpfeviewer.mcp", "xpfeviewer$D.shlb", "xpfeviewer.toc", 0, 0, 0);
}
@@ -722,11 +645,9 @@ sub BuildXPAppProjects()
my($D) = $main::DEBUG ? "Debug" : "";
my($dist_dir) = _getDistDirectory();
BuildOneProject(":mozilla:xpfe:appshell:macbuild:AppShell.mcp", "AppShell$D.shlb", "AppShell.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:xpfe:appshell:macbuild:AppShell.mcp", "AppShell$D.shlb", "AppShell.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:xpfe:AppCores:macbuild:AppCores.mcp", "AppCores$D.shlb", "AppCores.toc", 1, $main::ALIAS_SYM_FILES, 0);
BuildOneProject(":mozilla:xpfe:bootstrap:macbuild:apprunner.mcp", "apprunner$D", "apprunner.toc", 0, 0, 1);
BuildOneProject(":mozilla:xpfe:bootstrap:macbuild:apprunner.mcp", "apprunner$D", "apprunner.toc", 0, 0);
}

View File

@@ -1,96 +0,0 @@
#!perl
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
#
# nglayout build script (debug)
#
use Mac::Processes;
use NGLayoutBuildList;
use Cwd;
use Moz;
# configuration variables
$DEBUG = 1;
$ALIAS_SYM_FILES = $DEBUG;
$CLOBBER_LIBS = 1; # turn on to clobber existing libs and .xSYM files before
# building each project
$MOZ_FULLCIRCLE = 0;
$pull{all} = 1;
$pull{lizard} = 0;
$pull{xpcom} = 0;
$pull{imglib} = 0;
$pull{netlib} = 0;
$pull{nglayout} = 0;
$pull{mac} = 0;
$build{all} = 1; # turn off to do individual builds
$build{dist} = 0;
$build{stubs} = 0;
$build{common} = 0;
$build{nglayout} = 0;
$build{resources} = 0;
$build{editor} = 0;
$build{viewer} = 0;
$build{xpapp} = 0;
if ($pull{all})
{
foreach $k (keys(%pull))
{
$pull{$k} = 1;
}
}
if ($build{all})
{
foreach $k (keys(%build))
{
$build{$k} = 1;
}
}
# do the work
# you should not have to edit anything bellow
chdir("::::");
$MOZ_SRC = cwd();
if ($MOZ_FULLCIRCLE)
{
#// Get the Build Number for the Master.ini(Full Circle) n'stuff
$buildnum = Moz::SetBuildNumber();
}
OpenErrorLog("NGLayoutDebugBuildLog");
#OpenErrorLog("Mozilla.BuildLog"); # Tinderbox requires that name
Moz::StopForErrors();
#Moz::DontStopForErrors();
if ($pull{all}) {
Checkout();
}
chdir($MOZ_SRC);
BuildDist();
chdir($MOZ_SRC);
BuildProjects();
print "Build layout complete\n";

View File

@@ -29,7 +29,7 @@ use Moz;
$DEBUG = 1;
$ALIAS_SYM_FILES = 0;
$CLOBBER_LIBS = 1;
$CLOBBER_LIBS = 0;
$MOZ_FULLCIRCLE = 0;
$pull{all} = 0;

View File

@@ -1,84 +0,0 @@
#!perl
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
#
# nglayout build script (debug)
#
use NGLayoutBuildList;
use Cwd;
use Moz;
# configuration variables
$DEBUG = 0;
$ALIAS_SYM_FILES = 0;
$CLOBBER_LIBS = 1;
$MOZ_FULLCIRCLE = 0;
$pull{all} = 1;
$pull{lizard} = 0;
$pull{xpcom} = 0;
$pull{imglib} = 0;
$pull{netlib} = 0;
$pull{nglayout} = 0;
$pull{mac} = 0;
$build{all} = 1;
$build{dist} = 0;
$build{stubs} = 0;
$build{common} = 0;
$build{nglayout} = 0;
$build{resources} = 0;
$build{editor} = 0;
$build{viewer} = 0;
$build{xpapp} = 0;
# script
if ($pull{all})
{
foreach $k (keys(%pull))
{
$pull{$k} = 1;
}
}
if ($build{all})
{
foreach $k (keys(%build))
{
$build{$k} = 1;
}
}
# do the work
OpenErrorLog("::::Mozilla.BuildLog"); # Tinderbox requires that name
chdir("::::");
Checkout();
BuildDist();
BuildProjects();
print "Build NGLayout complete\n";

View File

@@ -1,2 +0,0 @@
This directory is merely here to test the project editor server. It will go away after
it is validated. For more information, see http://camelot.

Binary file not shown.

View File

@@ -1 +0,0 @@
// test1.cpp

View File

@@ -1 +0,0 @@
// test2.cpp

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More