Compare commits

..

47 Commits

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
2868 changed files with 106037 additions and 231629 deletions

View File

@@ -26,16 +26,17 @@ include $(DEPTH)/config/autoconf.mk
# nglayout test program. The order is important.
DIRS = \
config \
dbm \
nsprpub \
$(NULL)
ifndef MOZ_NATIVE_NSPR
ifndef MOZ_NATIVE_JPEG
DIRS += \
nsprpub \
jpeg \
$(NULL)
endif
DIRS += \
dbm \
modules/libreg \
xpcom \
$(NULL)
@@ -46,26 +47,23 @@ 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 \
gfx \
dom \
@@ -75,17 +73,11 @@ DIRS += \
rdf \
webshell \
editor \
silentdl \
sun-java \
$(NULL)
silentdl
DIRS += xpfe
ifdef MOZ_MAIL_NEWS
DIRS += mailnews
endif
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk

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,374 +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.
# This script outputs the list to the standard output.
# 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 write non-commented lines to stdout
add_makefiles() {
while read line; do
case $line in
\#*|dnl*) ;;
*) echo $line ;;
esac
done
}
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
gfx/Makefile
gfx/public/Makefile
gfx/src/Makefile
gfx/src/gtk/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
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/public/Makefile
rdf/base/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
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 <<END_MAILNEWS_MAKEFILES
network/protocol/certld/Makefile
network/protocol/imap4/Makefile
network/protocol/mailbox/Makefile
network/protocol/nntp/Makefile
network/protocol/pop3/Makefile
network/protocol/smtp/Makefile
mailnews/Makefile
mailnews/base/Makefile
mailnews/base/public/Makefile
mailnews/base/src/Makefile
mailnews/base/build/Makefile
mailnews/base/tests/Makefile
mailnews/db/Makefile
mailnews/db/mdb/Makefile
mailnews/db/mdb/public/Makefile
mailnews/db/msgdb/Makefile
mailnews/db/msgdb/public/Makefile
mailnews/db/msgdb/src/Makefile
mailnews/local/Makefile
mailnews/local/public/Makefile
mailnews/local/src/Makefile
mailnews/local/tests/Makefile
mailnews/local/tests/pop3/Makefile
mailnews/local/tests/mailbox/Makefile
mailnews/imap/Makefile
mailnews/imap/public/Makefile
mailnews/imap/src/Makefile
mailnews/news/Makefile
mailnews/news/public/Makefile
mailnews/news/src/Makefile
mailnews/news/tests/Makefile
mailnews/mime/Makefile
mailnews/mime/public/Makefile
mailnews/mime/src/Makefile
mailnews/compose/Makefile
mailnews/compose/public/Makefile
mailnews/compose/src/Makefile
mailnews/compose/tests/Makefile
mailnews/compose/tests/smtp/Makefile
mailnews/compose/tests/compose/Makefile
mailnews/ui/Makefile
mailnews/ui/messenger/Makefile
mailnews/ui/messenger/public/Makefile
mailnews/ui/messenger/src/Makefile
mailnews/ui/messenger/resources/Makefile
mailnews/ui/compose/Makefile
mailnews/ui/ab/Makefile
mailnews/public/Makefile
END_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,11 +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
nsFileSpec.h
nsRepeater.h
nsIProperties.h
nsCaretProperties.h
nsRepeater.h

View File

@@ -25,14 +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 \
$(NULL)
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))

View File

@@ -20,16 +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 \
$(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 PRUint32 GetCaretWidth() { return mCaretWidth; }
virtual PRUint32 GetCaretBlinkRate() { return mBlinkRate; }
protected:
// have value for no blinking
enum {
eDefaulBlinkRate = 500, // twice a second
eDefaultCaretWidth = 1 // one pixel wide
};
PRUint32 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,85 +137,33 @@
// 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 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 embeded 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)
{
*this = nsAutoCString(inPath);
}
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);
#ifndef XP_MAC
operator const char* () const { return mPath; }
@@ -241,22 +175,23 @@ class NS_BASE nsFileSpec
#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) {}
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; }
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);
@@ -264,15 +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 { return mError; }
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.
@@ -282,11 +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)
{
SetLeafName(nsAutoCString(inLeafName));
}
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,
@@ -294,11 +226,7 @@ class NS_BASE nsFileSpec
// but a spec. Volumes on Macintosh can have identical
// names. Perhaps could be used for an operator --() ?
nsFileSpec operator + (const char* inRelativePath) const;
nsFileSpec operator + (const nsString& inRelativePath) const
{
return *this + nsAutoCString(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.
@@ -308,44 +236,23 @@ 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)
{
*this += nsAutoCString(inRelativePath);
}
void MakeUnique();
void MakeUnique(const char* inSuggestedLeafName);
void MakeUnique(const nsString& inSuggestedLeafName)
{
MakeUnique(nsAutoCString(inSuggestedLeafName));
}
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)
{
return Rename(nsAutoCString(inNewName));
}
nsresult Copy(const nsFileSpec& inNewParentDirectory) const;
nsresult Move(const nsFileSpec& inNewParentDirectory) const;
nsresult Execute(const char* args) const;
nsresult Execute(const nsString& args) const
{
return Execute(nsAutoCString(args));
}
//--------------------------------------------------
// Data
//--------------------------------------------------
@@ -354,15 +261,11 @@ class NS_BASE nsFileSpec
friend class nsFilePath;
#ifdef XP_MAC
FSSpec mSpec;
OSErr mError;
#else
char* mPath;
#endif
nsresult mError;
}; // class nsFileSpec
// FOR HISTORICAL REASONS:
typedef nsFileSpec nsNativeFileSpec;
}; // class nsNativeFileSpec
//========================================================================================
class NS_BASE nsFileURL
@@ -373,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; }
@@ -385,19 +287,15 @@ class NS_BASE nsFileURL
void operator = (const nsFileURL& inURL);
void operator = (const char* inString);
void operator = (const nsString& inString)
{
*this = nsAutoCString(inString);
}
void operator = (const nsFilePath& inOther);
void operator = (const nsFileSpec& inOther);
void operator = (const nsNativeFileSpec& inOther);
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.
@@ -408,8 +306,8 @@ class NS_BASE nsFileURL
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
@@ -421,10 +319,9 @@ class NS_BASE nsFilePath
{
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();
@@ -439,17 +336,13 @@ class NS_BASE nsFilePath
void operator = (const nsFilePath& inPath);
void operator = (const char* inString);
void operator = (const nsString& inString)
{
*this = nsAutoCString(inString);
}
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:
@@ -457,62 +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
//========================================================================================
{
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
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);
private:
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
@@ -521,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,31 +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.
//
// nsInputFileStream, nsOutputFileStream
// These are the STATICALLY LINKED versions of the file i/o streams,
// which wrap the NSPR file i/o plus console i/o.
// single-byte char:
//
// Related files:
// prio.h the NSPR file i/o C API), which is wrapped by
// THIS FILE statically linked C++ wrappers, which in turn are wrapped by
// nsIFileStream.h COM wrappers for this file, which are wrapped by
// nsAutoFileStream.h more easily used, nicer syntax wrappers for the
// COMified ones. Wrapper of a wrapper of a wrapper.
// nsInputFileStream, nsOutputFileStream
//
// This suite provide the following services:
//
@@ -58,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
@@ -90,13 +73,7 @@
#else
#include "prio.h"
#endif
#include "nsIFileStream.h"
#include "nsCOMPtr.h"
class nsFileSpec;
class nsInputFileStream;
class nsOutputFileStream;
#include "nsFileSpec.h"
//========================================================================================
// Compiler-specific macros, as needed
@@ -156,467 +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)
{
if (!mInputStream)
return 0;
PRInt32 result = 0;
mInputStream->Read((char*)s, 0, n, (PRUint32*)&result);
if (result < n)
set_at_eof(PR_TRUE);
return result;
}
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)
{
if (!mOutputStream)
return 0;
PRInt32 result = 0;
mOutputStream->Write((char*)s, 0, n, (PRUint32*)&result);
return result;
}
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);
// 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 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:
nsFileClient() // for delayed opening
: mResult(NS_OK)
{
}
nsFileClient(const nsCOMPtr<nsIFile>& inFile)
: mFile(do_QueryInterface(inFile))
, mResult(NS_OK)
{
}
virtual ~nsFileClient() {}
PRInt32 write(const void* s, PRInt32 n);
void flush();
PRBool is_file() const
{
return mFile ? PR_TRUE : PR_FALSE;
}
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 failed() const
{
return NS_FAILED(mResult);
}
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);
ostream* GetStandardStream() const { return mStdStream; }
void seek(PRSeekWhence whence, PRInt32 offset)
{
set_at_eof(PR_FALSE);
if (mFile)
mResult = mFile->Seek(whence, offset);
}
PRIntn tell()
{
PRIntn result = -1;
if (mFile)
mResult = mFile->Tell(&result);
return result;
}
protected:
virtual PRBool get_at_eof() const
{
PRBool result;
if (mFile)
mFile->GetAtEOF(&result);
return result;
}
virtual void set_at_eof(PRBool atEnd)
{
if (mFile)
mFile->SetAtEOF(atEnd);
}
// DATA
protected:
nsCOMPtr<nsIFile> mFile;
PRBool mResult;
}; // class nsFileClient
nsBasicFileStream& mBase;
ostream* mStdStream;
}; // class nsBasicOutStream
//========================================================================================
class NS_BASE nsInputFileStream
// Please read the comments at the top of this file
//========================================================================================
: public nsInputStream
, public nsFileClient
: public nsBasicFileStream
, public nsBasicInStream
{
public:
enum { kDefaultMode = PR_RDONLY };
nsInputFileStream(nsIInputStream* inStream)
: nsInputStream(inStream)
, nsFileClient(do_QueryInterface(inStream))
, mFileInputStream(do_QueryInterface(inStream))
{
}
nsInputFileStream(istream* stream = CONSOLE_IN);
nsInputFileStream(
const nsFileSpec& inFile,
const nsFilePath& inFile,
int nsprMode = kDefaultMode,
PRIntn accessMode = 00700) // <- OCTAL
: nsInputStream(nsnull)
{
nsISupports* stream;
NS_NewIOFileStream(
&stream,
inFile, nsprMode, accessMode);
mFile = nsQueryInterface(stream);
mInputStream = nsQueryInterface(stream);
mFileInputStream = nsQueryInterface(stream);
NS_RELEASE(stream);
}
: nsBasicFileStream(inFile, nsprMode, accessMode)
, nsBasicInStream(*this, 0)
{}
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).
void Open(
const nsFileSpec& inFile,
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.
protected:
virtual PRBool get_at_eof() const
{
return nsFileClient::get_at_eof();
}
virtual void set_at_eof(PRBool atEnd)
{
nsFileClient::set_at_eof(atEnd);
}
// DATA
protected:
nsCOMPtr<nsIFileInputStream> mFileInputStream;
}; // class nsInputFileStream
//========================================================================================
class NS_BASE nsOutputFileStream
// Please read the comments at the top of this file
//========================================================================================
: public nsOutputStream
, public nsFileClient
: public nsBasicFileStream
, public nsBasicOutStream
{
public:
enum { kDefaultMode = (PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE) };
nsOutputFileStream() {}
nsOutputFileStream(nsIOutputStream* inStream)
: nsOutputStream(inStream)
, nsFileClient(do_QueryInterface(inStream))
, mFileOutputStream(do_QueryInterface(inStream))
{
}
nsOutputFileStream(ostream* stream = CONSOLE_OUT);
nsOutputFileStream(
const nsFileSpec& inFile,
const nsFilePath& inFile,
int nsprMode = kDefaultMode,
PRIntn accessMode = 00700) // <- OCTAL
: nsOutputStream(nsnull)
{
nsISupports* stream;
if (NS_FAILED(NS_NewIOFileStream(
&stream,
inFile, nsprMode, accessMode)))
return;
mFile = nsQueryInterface(stream);
mOutputStream = 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 << (nsOutputStream& (*pf)(nsOutputStream&))
{ return nsOutputStream::operator << (pf); }
protected:
virtual PRBool get_at_eof() const
inline void open(
const nsFilePath& inFile,
int nsprMode = kDefaultMode,
PRIntn accessMode = 00700) // <- OCTAL
{
return nsFileClient::get_at_eof();
nsBasicFileStream::open(inFile, nsprMode, accessMode);
}
virtual void set_at_eof(PRBool atEnd)
{
nsFileClient::set_at_eof(atEnd);
}
// DATA
protected:
nsCOMPtr<nsIFileOutputStream> mFileOutputStream;
}; // 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 << (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);
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 << (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,131 +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, Tell etc.
//========================================================================================
: public nsISupports
{
public:
static const nsIID& IID() { 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 Seek(PRSeekWhence whence, PRInt32 offset) = 0;
NS_IMETHOD GetIsOpen(PRBool* outOpen) = 0;
NS_IMETHOD Tell(PRIntn* outWhere) = 0;
/* "PROTECTED" */
NS_IMETHOD GetAtEOF(PRBool* outAtEOF) = 0;
NS_IMETHOD SetAtEOF(PRBool inAtEOF) = 0;
}; // class nsIFile
/* 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 nsISupports
{
public:
static const nsIID& IID() { 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 nsISupports
{
public:
static const nsIID& IID() { 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

@@ -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

@@ -31,7 +31,6 @@ LIBRARY_NAME = raptorbase
CPPSRCS = \
nsArena.cpp \
nsAtomTable.cpp \
nsBaseDLL.cpp \
nsBTree.cpp \
nsByteBuffer.cpp \
nsCRT.cpp \
@@ -39,8 +38,6 @@ CPPSRCS = \
nsEscape.cpp \
nsFileSpec.cpp \
nsFileStream.cpp \
nsIFileStream.cpp \
nsProperties.cpp \
nsRBTree.cpp \
nsSizeOfHandler.cpp \
nsString.cpp \

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/config.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

@@ -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

@@ -28,7 +28,6 @@
#include <Folders.h>
#include <Errors.h>
#include <TextUtils.h>
#include <Processes.h>
const unsigned char* kAliasHavenFolderName = "\pnsAliasHaven";
@@ -75,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);
@@ -132,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.
@@ -146,8 +145,8 @@ char* MacFileHelpers::EncodeMacPath(
pathSize--;
}
char * newPath = nsnull;
char * finalPath = nsnull;
char * newPath = NULL;
char * finalPath = NULL;
if (prependSlash)
{
@@ -189,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
@@ -222,9 +221,9 @@ char* MacFileHelpers::MacPathFromUnixPath(const char* unixPath)
{
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);
nsUnescape(dst); // Hex Decode
@@ -347,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.
//----------------------------------------------------------------------------------------
@@ -380,7 +379,7 @@ OSErr MacFileHelpers::FSSpecFromFullUnixPath(
// 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);
if (!macPath)
@@ -414,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 )
@@ -472,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 );
@@ -501,19 +500,19 @@ Clean:
} // MacFileHelpers::PathNameFromFSSpec
//========================================================================================
// Macintosh nsFileSpec implementation
// Macintosh nsNativeFileSpec implementation
//========================================================================================
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec()
nsNativeFileSpec::nsNativeFileSpec()
//----------------------------------------------------------------------------------------
: mError(NS_OK)
: mError(noErr)
{
mSpec.name[0] = '\0';
}
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsFileSpec& inSpec)
nsNativeFileSpec::nsNativeFileSpec(const nsNativeFileSpec& inSpec)
//----------------------------------------------------------------------------------------
: mSpec(inSpec.mSpec)
, mError(inSpec.Error())
@@ -521,101 +520,87 @@ nsFileSpec::nsFileSpec(const nsFileSpec& inSpec)
}
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const char* inString, PRBool inCreateDirs)
nsNativeFileSpec::nsNativeFileSpec(const char* inString, bool inCreateDirs)
//----------------------------------------------------------------------------------------
{
mError = NS_FILE_RESULT(MacFileHelpers::FSSpecFromFullUnixPath(
inString, mSpec, false, true, inCreateDirs));
mError = MacFileHelpers::FSSpecFromFullUnixPath(
inString, mSpec, true, true, inCreateDirs);
// allow a partial path, create as necessary
if (mError == NS_FILE_RESULT(fnfErr))
mError = NS_OK;
} // nsFileSpec::nsFileSpec
if (mError == fnfErr)
mError = noErr;
} // nsNativeFileSpec::nsNativeFileSpec
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsString& inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
{
mError = NS_FILE_RESULT(MacFileHelpers::FSSpecFromFullUnixPath(
nsAutoCString(inString), mSpec, false, true, inCreateDirs));
// allow a partial path, create as necessary
if (mError == NS_FILE_RESULT(fnfErr))
mError = NS_OK;
} // nsFileSpec::nsFileSpec
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(
nsNativeFileSpec::nsNativeFileSpec(
short vRefNum,
long parID,
ConstStr255Param name)
//----------------------------------------------------------------------------------------
{
mError = NS_FILE_RESULT(::FSMakeFSSpec(vRefNum, parID, name, &mSpec));
if (mError == NS_FILE_RESULT(fnfErr))
mError = ::FSMakeFSSpec(vRefNum, parID, name, &mSpec);
if (mError == fnfErr)
mError = noErr;
}
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsFilePath& inPath)
nsNativeFileSpec::nsNativeFileSpec(const nsFilePath& inPath)
//----------------------------------------------------------------------------------------
{
*this = inPath.GetFileSpec();
*this = inPath.GetNativeSpec();
}
#if DEBUG
//----------------------------------------------------------------------------------------
nsOutputStream& operator << (nsOutputStream& s, const nsFileSpec& spec)
nsBasicOutStream& operator << (nsBasicOutStream& s, const nsNativeFileSpec& spec)
//----------------------------------------------------------------------------------------
{
s << spec.mSpec.vRefNum << ", " << spec.mSpec.parID << ", \"";
s.write((const char*)&spec.mSpec.name[1], spec.mSpec.name[0]);
return s << "\"";
} // nsOutputStream& operator << (nsOutputStream&, const nsFileSpec&)
#endif
} // nsOutputFileStream& operator << (nsOutputFileStream&, const nsNativeFileSpec&)
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const char* inString)
void nsNativeFileSpec::operator = (const char* inString)
//----------------------------------------------------------------------------------------
{
mError = NS_FILE_RESULT(MacFileHelpers::FSSpecFromFullUnixPath(inString, mSpec, false));
} // nsFileSpec::operator =
mError = MacFileHelpers::FSSpecFromFullUnixPath(inString, mSpec, true);
} // nsNativeFileSpec::operator =
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const nsFileSpec& inSpec)
void nsNativeFileSpec::operator = (const nsNativeFileSpec& inSpec)
//----------------------------------------------------------------------------------------
{
mSpec = inSpec.mSpec;
mError = inSpec.Error();
} // nsFileSpec::operator =
} // nsNativeFileSpec::operator =
//----------------------------------------------------------------------------------------
void nsFileSpec::operator = (const nsFilePath& inPath)
void nsNativeFileSpec::operator = (const nsFilePath& inPath)
//----------------------------------------------------------------------------------------
{
*this = inPath.GetFileSpec();
} // nsFileSpec::operator =
*this = inPath.GetNativeSpec();
} // nsNativeFileSpec::operator =
//----------------------------------------------------------------------------------------
PRBool nsFileSpec::Exists() const
bool nsNativeFileSpec::Exists() const
//----------------------------------------------------------------------------------------
{
FSSpec temp;
return ::FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, mSpec.name, &temp) == noErr;
} // nsFileSpec::operator =
} // nsNativeFileSpec::operator =
//----------------------------------------------------------------------------------------
void nsFileSpec::SetLeafName(const char* inLeafName)
void nsNativeFileSpec::SetLeafName(const char* inLeafName)
// In leaf name can actually be a partial path...
//----------------------------------------------------------------------------------------
{
// what about long relative paths? Hmm?
Str255 partialPath;
MacFileHelpers::PLstrcpy(partialPath, inLeafName);
mError = NS_FILE_RESULT(
::FSMakeFSSpec(mSpec.vRefNum, mSpec.parID, partialPath, &mSpec));
} // 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.
//----------------------------------------------------------------------------------------
{
@@ -623,219 +608,131 @@ 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()
//----------------------------------------------------------------------------------------
{
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)
//----------------------------------------------------------------------------------------
{
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)
{
Str255 partialPath;
MacFileHelpers::PLstrcpy(partialPath, inRelativePath);
mError = NS_FILE_RESULT(::FSMakeFSSpec(mSpec.vRefNum, dirID, partialPath, *this));
//if (NS_SUCCEEDED(mError))
// SetLeafName(inRelativePath);
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;
FSpDirCreate(&mSpec, smCurrentScript, &ignoredDirID);
} // nsFileSpec::CreateDirectory
} // 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
//========================================================================================
// 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 );
char * path = MacFileHelpers::PathNameFromFSSpec( mNativeFileSpec, TRUE );
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
}
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const nsString& inString, PRBool inCreateDirs)
nsFilePath::nsFilePath(const nsNativeFileSpec& inSpec)
//----------------------------------------------------------------------------------------
: mPath(nsnull)
, mFileSpec(nsAutoCString(inString), inCreateDirs)
{
// Make canonical and absolute.
char * path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, TRUE );
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
}
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const nsFileSpec& inSpec)
//----------------------------------------------------------------------------------------
: mFileSpec(inSpec)
: mNativeFileSpec(inSpec)
{
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, TRUE );
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
}
//----------------------------------------------------------------------------------------
void nsFilePath::operator = (const nsFileSpec& inSpec)
void nsFilePath::operator = (const nsNativeFileSpec& inSpec)
//----------------------------------------------------------------------------------------
{
delete [] mPath;
char * path = MacFileHelpers::PathNameFromFSSpec( inSpec.mSpec, TRUE );
mPath = MacFileHelpers::EncodeMacPath(path, true, true);
mFileSpec = inSpec;
mNativeFileSpec = inSpec;
} // nsFilePath::operator =
//========================================================================================
@@ -843,31 +740,14 @@ void nsFilePath::operator = (const nsFileSpec& inSpec)
//========================================================================================
//----------------------------------------------------------------------------------------
nsFileURL::nsFileURL(const char* inString, PRBool inCreateDirs)
nsFileURL::nsFileURL(const char* inString, bool inCreateDirs)
//----------------------------------------------------------------------------------------
: mURL(nsnull)
, mFileSpec(inString + kFileURLPrefixLength, inCreateDirs)
, mNativeFileSpec(inString + kFileURLPrefixLength, inCreateDirs)
{
NS_ASSERTION(strstr(inString, kFileURLPrefix) == inString, "Not a URL!");
// Make canonical and absolute.
char* path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, TRUE );
char* escapedPath = MacFileHelpers::EncodeMacPath(path, true, true);
mURL = nsFileSpecHelpers::StringDup(kFileURLPrefix, kFileURLPrefixLength + strlen(escapedPath));
strcat(mURL, escapedPath);
delete [] escapedPath;
} // nsFileURL::nsFileURL
//----------------------------------------------------------------------------------------
nsFileURL::nsFileURL(const nsString& inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
: mURL(nsnull)
{
nsAutoCString aString(inString);
const char* aCString = (const char*)aString;
NS_ASSERTION(strstr(aCString, kFileURLPrefix) == aCString, "Not a URL!");
mFileSpec = aCString + kFileURLPrefixLength;
// Make canonical and absolute.
char* path = MacFileHelpers::PathNameFromFSSpec( mFileSpec, TRUE );
char* path = MacFileHelpers::PathNameFromFSSpec( mNativeFileSpec, TRUE );
char* escapedPath = MacFileHelpers::EncodeMacPath(path, true, true);
mURL = nsFileSpecHelpers::StringDup(kFileURLPrefix, kFileURLPrefixLength + strlen(escapedPath));
strcat(mURL, escapedPath);
@@ -880,7 +760,7 @@ nsFileURL::nsFileURL(const nsString& inString, PRBool inCreateDirs)
//----------------------------------------------------------------------------------------
nsDirectoryIterator::nsDirectoryIterator(
const nsFileSpec& inDirectory
const nsNativeFileSpec& inDirectory
, int inIterateDirection)
//----------------------------------------------------------------------------------------
: mCurrent(inDirectory)
@@ -890,7 +770,7 @@ nsDirectoryIterator::nsDirectoryIterator(
CInfoPBRec pb;
DirInfo* dipb = (DirInfo*)&pb;
// Sorry about this, there seems to be a bug in CWPro 4:
const FSSpec& inSpec = inDirectory.nsFileSpec::operator const FSSpec&();
const FSSpec& inSpec = inDirectory.nsNativeFileSpec::operator const FSSpec&();
Str255 outName;
MacFileHelpers::PLstrcpy(outName, inSpec.name);
pb.hFileInfo.ioNamePtr = outName;
@@ -904,7 +784,7 @@ nsDirectoryIterator::nsDirectoryIterator(
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&();
FSSpec& currentSpec = mCurrent.nsNativeFileSpec::operator FSSpec&();
currentSpec.vRefNum = inSpec.vRefNum;
currentSpec.parID = dipb->ioDrDirID;
mMaxIndex = pb.dirInfo.ioDrNmFls;
@@ -927,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;

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
@@ -144,8 +140,6 @@ TimerImpl::TimerImpl()
, mClosure(nsnull)
, mDelay(0)
, mFireTime(0)
, mPrev(nsnull)
, mNext(nsnull)
#if DEBUG
, mSignature(eGoodTimerSignature)
#endif
@@ -191,6 +185,7 @@ nsresult TimerImpl::Init(nsITimerCallback *aCallback,
void TimerImpl::Cancel()
//----------------------------------------------------------------------------------------
{
TimerPeriodical::GetPeriodical()->RemoveTimer(this);
}
@@ -256,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;
}
@@ -329,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);
}
}

View File

@@ -40,8 +40,6 @@ CPPSRCS = \
nsVoidArray.cpp \
nsFileSpec.cpp \
nsFileStream.cpp \
nsEscape.cpp \
nsIFileStream.cpp \
$(NULL)
CPP_OBJS = \
@@ -61,8 +59,6 @@ CPP_OBJS = \
.\$(OBJDIR)\nsVoidArray.obj \
.\$(OBJDIR)\nsFileSpec.obj \
.\$(OBJDIR)\nsFileStream.obj \
.\$(OBJDIR)\nsEscape.obj \
.\$(OBJDIR)\nsIFileStream.obj \
$(NULL)
EXPORTS=nscore.h nsIArena.h nsIAtom.h nsIByteBuffer.h \
@@ -75,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) \

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

@@ -130,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

@@ -22,17 +22,17 @@
#include "nsProperties.h"
#include "nsRepository.h"
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 ret;
ret = nsRepository::RegisterComponent(kPropertiesCID, NULL, NULL,
path, PR_TRUE, PR_TRUE);
ret = nsRepository::RegisterFactory(kPropertiesCID, path, PR_TRUE,
PR_TRUE);
if (NS_FAILED(ret)) {
return ret;
}
@@ -41,7 +41,7 @@ NSRegisterSelf(nsISupports* aServMgr, const char* path)
}
extern "C" NS_EXPORT nsresult
NSUnregisterSelf(nsISupports* aServMgr, const char* path)
NSUnregisterSelf(const char* path)
{
nsresult ret;
@@ -54,11 +54,7 @@ NSUnregisterSelf(nsISupports* aServMgr, const char* path)
}
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;
@@ -82,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

@@ -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,53 +138,9 @@ PRUnichar nsCRT::ToLower(PRUnichar aChar)
return TOLOWER(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)
PRInt32 nsCRT::strlen(const PRUnichar* s)
{
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++;
@@ -284,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) {
@@ -296,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;
@@ -338,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){
@@ -394,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) {
@@ -406,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;
@@ -448,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) {
@@ -464,7 +360,7 @@ PRInt32 nsCRT::strncasecmp(const PRUnichar* s1, const char* s2, PRUint32 n)
}
}
if (c1 == 0) break;
} while (--n != 0);
}
}
}
return 0;
@@ -472,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));
@@ -492,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 );

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,7 +62,7 @@ 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)
//----------------------------------------------------------------------------------------
{
int32 i, extra = 0;
@@ -109,7 +109,7 @@ NS_BASE char* nsEscapeCount(const char * str, PRInt32 len, nsEscapeMask mask, PR
}
//----------------------------------------------------------------------------------------
NS_BASE char* nsUnescape(char * str)
char* nsUnescape(char * str)
//----------------------------------------------------------------------------------------
{
nsUnescapeCount(str);
@@ -117,7 +117,7 @@ NS_BASE char* nsUnescape(char * str)
}
//----------------------------------------------------------------------------------------
NS_BASE PRInt32 nsUnescapeCount(char * str)
PRInt32 nsUnescapeCount(char * str)
//----------------------------------------------------------------------------------------
{
register char *src = str;

View File

@@ -22,9 +22,6 @@
#include "nsDebug.h"
#include "prtypes.h"
#include "plstr.h"
#include "plbase64.h"
#include "prmem.h"
#include <string.h>
#include <stdio.h>
@@ -43,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
@@ -57,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(
@@ -76,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
@@ -88,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));
@@ -106,7 +95,7 @@ char* nsFileSpecHelpers::StringAssign(
if (!inString2)
{
delete [] ioString;
ioString = (char*)nsnull;
ioString = (char*)NULL;
return ioString;
}
if (!ioString || (strlen(inString2) > strlen(ioString)))
@@ -136,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);
@@ -156,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)
@@ -171,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,7 +177,7 @@ void nsFileSpecHelpers::MakeAllDirectories(const char* inPath, int mode)
if (currentEnd)
{
*currentEnd = '\0';
nsFileSpec spec(nsFilePath(pathCopy, PR_FALSE));
nsNativeFileSpec spec(nsFilePath(pathCopy, false));
do
{
// If the node doesn't exist, and it is not the initial node in a full path,
@@ -258,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
@@ -274,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)
{
@@ -287,29 +238,12 @@ 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
@@ -319,16 +253,16 @@ nsFileURL::nsFileURL(const nsFilePath& inOther)
//----------------------------------------------------------------------------------------
: mURL(nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)inOther))
#ifdef XP_MAC
, mFileSpec(inOther.GetFileSpec())
, mNativeFileSpec(inOther.GetNativeSpec())
#endif
{
} // nsFileURL::nsFileURL
//----------------------------------------------------------------------------------------
nsFileURL::nsFileURL(const nsFileSpec& inOther)
nsFileURL::nsFileURL(const nsNativeFileSpec& inOther)
: mURL(nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)nsFilePath(inOther)))
#ifdef XP_MAC
, mFileSpec(inOther)
, mNativeFileSpec(inOther)
#endif
//----------------------------------------------------------------------------------------
{
@@ -348,7 +282,7 @@ void nsFileURL::operator = (const char* inString)
nsFileSpecHelpers::StringAssign(mURL, inString);
NS_ASSERTION(strstr(inString, kFileURLPrefix) == inString, "Not a URL!");
#ifdef XP_MAC
mFileSpec = inString + kFileURLPrefixLength;
mNativeFileSpec = inString + kFileURLPrefixLength;
#endif
} // nsFileURL::operator =
@@ -358,7 +292,7 @@ void nsFileURL::operator = (const nsFileURL& inOther)
{
mURL = nsFileSpecHelpers::StringAssign(mURL, inOther.mURL);
#ifdef XP_MAC
mFileSpec = inOther.GetFileSpec();
mNativeFileSpec = inOther.GetNativeSpec();
#endif
} // nsFileURL::operator =
@@ -369,24 +303,23 @@ void nsFileURL::operator = (const nsFilePath& inOther)
delete [] mURL;
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)inOther);
#ifdef XP_MAC
mFileSpec = inOther.GetFileSpec();
mNativeFileSpec = inOther.GetNativeSpec();
#endif
} // nsFileURL::operator =
//----------------------------------------------------------------------------------------
void nsFileURL::operator = (const nsFileSpec& inOther)
void nsFileURL::operator = (const nsNativeFileSpec& inOther)
//----------------------------------------------------------------------------------------
{
delete [] mURL;
mURL = nsFileSpecHelpers::AllocCat(kFileURLPrefix, (const char*)nsFilePath(inOther));
#ifdef XP_MAC
mFileSpec = inOther;
mNativeFileSpec = inOther;
#endif
} // nsFileURL::operator =
//----------------------------------------------------------------------------------------
nsOutputStream& operator << (nsOutputStream& s, const nsFileURL& url)
nsBasicOutStream& operator << (nsBasicOutStream& s, const nsFileURL& url)
//----------------------------------------------------------------------------------------
{
return (s << url.mURL);
@@ -396,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))
{
@@ -424,39 +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
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const nsFileURL& inOther)
//----------------------------------------------------------------------------------------
: mPath(nsFileSpecHelpers::StringDup(inOther.mURL + kFileURLPrefixLength))
#ifdef XP_MAC
, mFileSpec(inOther.GetFileSpec())
, mNativeFileSpec(inOther.GetNativeSpec())
#endif
{
}
#ifdef XP_UNIX
//----------------------------------------------------------------------------------------
nsFilePath::nsFilePath(const nsFileSpec& inOther)
nsFilePath::nsFilePath(const nsNativeFileSpec& inOther)
//----------------------------------------------------------------------------------------
: mPath(nsFileSpecHelpers::StringDup(inOther.mPath))
{
@@ -472,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);
@@ -485,15 +390,14 @@ 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
@@ -506,66 +410,45 @@ void nsFilePath::operator = (const nsFileURL& inOther)
{
nsFileSpecHelpers::StringAssign(mPath, (const char*)nsFilePath(inOther));
#ifdef XP_MAC
mFileSpec = inOther.GetFileSpec();
#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)
//----------------------------------------------------------------------------------------
#ifndef XP_MAC
: mPath(nsnull)
#endif
{
*this = inDescriptor;
}
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsFileURL& inURL)
//----------------------------------------------------------------------------------------
#ifndef XP_MAC
: mPath(nsnull)
: 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())
@@ -584,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++)
{
@@ -596,94 +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);
#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);
@@ -691,7 +531,7 @@ nsFileSpec::nsFileSpec(const nsString& inString, PRBool inCreateDirs)
#endif //XP_UNIX,PC
//----------------------------------------------------------------------------------------
nsFileSpec::~nsFileSpec()
nsNativeFileSpec::~nsNativeFileSpec()
//----------------------------------------------------------------------------------------
{
#ifndef XP_MAC
@@ -701,30 +541,28 @@ nsFileSpec::~nsFileSpec()
#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_TRUE /* 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)
//----------------------------------------------------------------------------------------
{
return (s << (const char*)spec.mPath);
@@ -732,158 +570,10 @@ nsOutputStream& operator << (nsOutputStream& s, const nsFileSpec& spec)
#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 +
//========================================================================================
// 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;
/*
This is killing the tree. mcmullen will need to look at this.
OSErr err = NewAlias(nil, inSpec.operator const FSSpec* const (), &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);
#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(aStream) >> *this;
return NS_OK;
}
//----------------------------------------------------------------------------------------
nsresult nsPersistentFileDescriptor::Write(nsIOutputStream* aStream)
//----------------------------------------------------------------------------------------
{
nsOutputStream(aStream) << *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", &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,169 +22,419 @@
#include "nsFileStream.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);
}
//----------------------------------------------------------------------------------------
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).
nsBasicFileStream::nsBasicFileStream(PRFileDesc* desc, int nsprMode)
//----------------------------------------------------------------------------------------
: mFileDesc(desc)
, mNSPRMode(nsprMode)
, mFailed(false)
, mEOF(false)
{
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();
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
//========================================================================================
// nsBasicInStream
//========================================================================================
//----------------------------------------------------------------------------------------
nsBasicInStream::nsBasicInStream(nsBasicFileStream& inBasicStream, istream* inStream)
//----------------------------------------------------------------------------------------
: mBase(inBasicStream)
, mStdStream(inStream)
{
}
//----------------------------------------------------------------------------------------
void nsBasicInStream::get(char& c)
//----------------------------------------------------------------------------------------
{
read(&c, sizeof(char));
}
//----------------------------------------------------------------------------------------
PRBool nsBasicInStream::readline(char* s, PRInt32 n)
// This will truncate if the buffer is too small. Result will always be null-terminated.
//----------------------------------------------------------------------------------------
{
PRBool bufferLargeEnough = true; // result
if (!s || !n)
return true;
PRIntn position = mBase.tell();
if (position < 0)
return false;
PRInt32 bytesRead = read(s, n - 1);
if (mBase.failed())
return false;
s[bytesRead] = '\0'; // always terminate at the end of the buffer
char* tp = strpbrk(s, "\n\r");
if (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 (!mBase.eof())
bufferLargeEnough = false;
position += bytesRead;
mBase.seek(position);
return bufferLargeEnough;
} // nsBasicInStream::getline
//----------------------------------------------------------------------------------------
PRInt32 nsBasicInStream::read(void* s, PRInt32 n)
//----------------------------------------------------------------------------------------
{
#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;
}
//----------------------------------------------------------------------------------------
nsBasicInStream& nsBasicInStream::operator >> (char& c)
//----------------------------------------------------------------------------------------
{
get(c);
return *this;
}
//========================================================================================
// nsOutputStream
//========================================================================================
//----------------------------------------------------------------------------------------
nsOutputStream::~nsOutputStream()
//----------------------------------------------------------------------------------------
{
}
//----------------------------------------------------------------------------------------
void nsOutputStream::put(char c)
//----------------------------------------------------------------------------------------
{
write(&c, sizeof(c));
}
//----------------------------------------------------------------------------------------
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, "%d", val);
return (*this << buf);
}
//----------------------------------------------------------------------------------------
nsOutputStream& nsOutputStream::operator << (unsigned short val)
//----------------------------------------------------------------------------------------
{
char buf[30];
sprintf(buf, "%ud", 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, "%uld", val);
return (*this << buf);
}
//========================================================================================
// nsInputFileStream
//========================================================================================
//----------------------------------------------------------------------------------------
PRBool nsInputFileStream::readline(char* s, PRInt32 n)
// This will truncate if the buffer is too small. Result will always be null-terminated.
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)
//----------------------------------------------------------------------------------------
{
PRBool bufferLargeEnough = PR_TRUE; // result
if (!s || !n)
return PR_TRUE;
write(&c, sizeof(c));
}
PRIntn position = tell();
if (position < 0)
return PR_FALSE;
PRInt32 bytesRead = read(s, n - 1);
if (failed())
return PR_FALSE;
s[bytesRead] = '\0'; // always terminate at the end of the buffer
char* tp = strpbrk(s, "\n\r");
if (tp)
//----------------------------------------------------------------------------------------
PRInt32 nsBasicOutStream::write(const void* s, PRInt32 n)
//----------------------------------------------------------------------------------------
{
#ifndef NS_USE_PR_STDIO
// Calling PR_Write on stdout is sure suicide.
if (mStdStream)
{
TidyEndOfLine(tp);
bytesRead = (tp - s);
mStdStream->write((const char*)s, n);
return n;
}
else if (!eof())
bufferLargeEnough = PR_FALSE;
position += bytesRead;
seek(position);
return bufferLargeEnough;
} // nsInputStream::readline
#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;
}
#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();
}
//========================================================================================
@@ -192,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& IID() { 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& IID() { static nsIID iid = NS_IBASESTREAM_IID; return iid; }
/** Close the stream. */
NS_IMETHOD
Close(void) = 0;

View File

@@ -1,462 +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 nsIOutputStream
, public nsIInputStream
, 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 aOffset,
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;
if (aOffset)
PR_Seek(mFileDesc, aOffset, PR_SEEK_CUR);
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 aOffset,
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;
if (aOffset)
PR_Seek(mFileDesc, aOffset, PR_SEEK_CUR);
PRInt32 bytesWrit = PR_Write(mFileDesc, aBuf, aCount);
if (bytesWrit != 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::IID())) \
{ \
*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(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)->IID()))
{
*aInstancePtr = (void*)((nsIBaseStream*)(nsIOutputStream*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(((nsISupports*)(nsIOutputStream*)this)->IID()))
{
*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;
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;
}
else if (newPosition >= fileSize)
{
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& IID() { 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

View File

@@ -29,8 +29,6 @@
class nsIOutputStream : public nsIBaseStream {
public:
static const nsIID& IID() { 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

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_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

@@ -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,14 +431,6 @@ nsString nsString::operator+(PRUnichar aChar) {
*/
void nsString::ToLowerCase()
{
// I18N code begin
CheckCaseConversion();
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) {
@@ -512,14 +448,6 @@ void nsString::ToLowerCase()
*/
void nsString::ToUpperCase()
{
// I18N code begin
CheckCaseConversion();
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) {
@@ -540,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++;
}
}
@@ -559,17 +486,6 @@ void nsString::ToLowerCase(nsString& aOut) const
{
aOut.EnsureCapacityFor(mLength);
aOut.mLength = mLength;
// I18N code begin
CheckCaseConversion();
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;
@@ -593,16 +509,6 @@ void nsString::ToUpperCase(nsString& aOut) const
{
aOut.EnsureCapacityFor(mLength);
aOut.mLength = mLength;
// I18N code begin
CheckCaseConversion();
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;
@@ -758,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{
@@ -1359,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) {
@@ -1401,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,
@@ -1799,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);}
@@ -2151,6 +2032,7 @@ ostream& operator<<(ostream& os,nsAutoString& aString){
}
/**
*
* @update gess 7/27/98
@@ -2170,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

@@ -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)
@@ -164,8 +164,5 @@ typedef PRUcs2 PRUnichar;
// No sense in making an NS_DYNAMIC_CAST() macro: you can't duplicate
// the semantics. So if you want to dynamic_cast, then just use it
// "straight", no macro.
#if defined(AIX)
#define explicit
#endif
#endif /* nscore_h___ */

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,10 +25,9 @@
#include <dirent.h>
#include <unistd.h>
#include <stdlib.h>
#include "nsError.h"
//----------------------------------------------------------------------------------------
void nsFileSpecHelpers::Canonify(char*& ioPath, PRBool inMakeDirs)
void nsFileSpecHelpers::Canonify(char*& ioPath, bool inMakeDirs)
// Canonify, make absolute, and check whether directories exist
//----------------------------------------------------------------------------------------
{
@@ -77,78 +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
//----------------------------------------------------------------------------------------
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?
//----------------------------------------------------------------------------------------
{
@@ -156,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);
}
}
@@ -166,151 +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, ( strlen(inParentDirectory) + 1 + strlen(leafname) ) );
strcat(destPath, "/");
strcat(destPath, leafname);
delete [] leafname;
result = NS_FILE_RESULT(CrudeFileCopy(*this, 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,
strlen(inNewParentDirectory) + 1 + strlen(leafname));
strcat(destPath, "/");
strcat(destPath, leafname);
delete [] leafname;
result = NS_FILE_RESULT(CrudeFileCopy(*this, 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
} // nsNativeFileSpec::Delete
//========================================================================================
// nsDirectoryIterator
@@ -318,12 +170,12 @@ nsresult nsFileSpec::Execute(const char* inArgs ) const
//----------------------------------------------------------------------------------------
nsDirectoryIterator::nsDirectoryIterator(
const nsFileSpec& inDirectory
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));
@@ -342,7 +194,7 @@ nsDirectoryIterator::~nsDirectoryIterator()
nsDirectoryIterator& nsDirectoryIterator::operator ++ ()
//----------------------------------------------------------------------------------------
{
mExists = PR_FALSE;
mExists = false;
if (!mDir)
return *this;
char* dot = ".";
@@ -354,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 = 2; // 2 pixel caret on Windows
}
//-----------------------------------------------------------------------------
nsCaretProperties* NewCaretProperties()
{
return new nsCaretProperties();
}

View File

@@ -23,18 +23,9 @@
#include <direct.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.
@@ -134,7 +125,7 @@ void nsFileSpecHelpers::NativeToUnix(char*& ioPath)
}
//----------------------------------------------------------------------------------------
nsFileSpec::nsFileSpec(const nsFilePath& inPath)
nsNativeFileSpec::nsNativeFileSpec(const nsFilePath& inPath)
//----------------------------------------------------------------------------------------
: mPath(NULL)
{
@@ -142,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)
{
@@ -159,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);
@@ -167,195 +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
//----------------------------------------------------------------------------------------
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 (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);
} // 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
} // nsNativeFileSpec::Delete
//========================================================================================
// nsDirectoryIterator
@@ -363,12 +252,12 @@ nsresult nsFileSpec::Execute(const char* inArgs ) 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";
@@ -387,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;

View File

@@ -1,27 +1,7 @@
/* -*- 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 "string.h"
#include "nsFileSpec.h"
#include "nsFileStream.h"
//#include "string.h"
//void* operator new(size_t n) { return malloc(n); }
struct FilesTest
{
FilesTest() : mConsole() {}
@@ -32,25 +12,18 @@ struct FilesTest
int InputStream(const char* relativePath);
int OutputStream(const char* relativePath);
int IOStream(const char* relativePath);
int Parent(const char* relativePath, nsFileSpec& outParent);
int Delete(nsFileSpec& victim);
int CreateDirectory(nsFileSpec& victim);
int IterateDirectoryChildren(nsFileSpec& startChild);
int Parent(const char* relativePath, nsNativeFileSpec& outParent);
int Delete(nsNativeFileSpec& victim);
int CreateDirectory(nsNativeFileSpec& victim);
int IterateDirectoryChildren(nsNativeFileSpec& startChild);
int CanonicalPath(const char* relativePath);
int Persistence(const char* relativePath);
int Copy(const char* sourceFile, const char* targDir);
int Move(const char* sourceFile, const char* targDir);
int Rename(const char* sourceFile, const char* newName);
int Execute(const char* appName, const char* args);
void Banner(const char* bannerString);
void Passed();
void Failed();
void Inspect();
nsOutputConsoleStream mConsole;
nsOutputFileStream mConsole;
};
//----------------------------------------------------------------------------------------
@@ -68,8 +41,7 @@ void FilesTest::Banner(const char* bannerString)
void FilesTest::Passed()
//----------------------------------------------------------------------------------------
{
((nsOutputStream&)mConsole) << "Test passed.";
mConsole << nsEndl;
mConsole << "Test passed." << nsEndl;
}
//----------------------------------------------------------------------------------------
@@ -91,7 +63,7 @@ void FilesTest::WriteStuff(nsOutputFileStream& s)
//----------------------------------------------------------------------------------------
{
// Initialize a URL from a string without suffix. Change the path to suit your machine.
nsFileURL fileURL("file:///Development/MPW/MPW%20Shell", PR_FALSE);
nsFileURL fileURL("file:///Development/MPW/MPW%20Shell", false);
s << "File URL initialized to: \"" << fileURL << "\""<< nsEndl;
// Initialize a Unix path from a URL
@@ -99,7 +71,7 @@ void FilesTest::WriteStuff(nsOutputFileStream& s)
s << "As a unix path: \"" << (const char*)filePath << "\""<< nsEndl;
// Initialize a native file spec from a URL
nsFileSpec fileSpec(fileURL);
nsNativeFileSpec fileSpec(fileURL);
s << "As a file spec: " << fileSpec << nsEndl;
// Make the spec unique (this one has no suffix).
@@ -127,12 +99,12 @@ void FilesTest::WriteStuff(nsOutputFileStream& s)
int FilesTest::OutputStream(const char* relativePath)
//----------------------------------------------------------------------------------------
{
nsFilePath myTextFilePath(relativePath, PR_TRUE); // relative path.
nsFilePath myTextFilePath(relativePath, true); // relative path.
const char* pathAsString = (const char*)myTextFilePath;
nsFileSpec mySpec(myTextFilePath);
nsNativeFileSpec mySpec(myTextFilePath);
{
mConsole << "WRITING IDENTICAL OUTPUT TO " << pathAsString << nsEndl << nsEndl;
nsOutputFileStream testStream(mySpec);
nsOutputFileStream testStream(myTextFilePath);
if (!testStream.is_open())
{
mConsole
@@ -162,12 +134,11 @@ int FilesTest::OutputStream(const char* relativePath)
int FilesTest::IOStream(const char* relativePath)
//----------------------------------------------------------------------------------------
{
nsFilePath myTextFilePath(relativePath, PR_TRUE); // relative path.
nsFilePath myTextFilePath(relativePath, true); // relative path.
const char* pathAsString = (const char*)myTextFilePath;
nsFileSpec mySpec(myTextFilePath);
mConsole
<< "Replacing \"path\" by \"ZUUL\" in " << pathAsString << nsEndl << nsEndl;
nsIOFileStream testStream(mySpec);
nsIOFileStream testStream(myTextFilePath);
if (!testStream.is_open())
{
mConsole
@@ -177,7 +148,7 @@ int FilesTest::IOStream(const char* relativePath)
<< nsEndl;
return -1;
}
char line[5000]; // Use a buffer longer than the file!
char line[1000];
testStream.seek(0); // check that the seek compiles
while (!testStream.eof())
{
@@ -194,66 +165,14 @@ int FilesTest::IOStream(const char* relativePath)
return 0;
}
//----------------------------------------------------------------------------------------
int FilesTest::Persistence(
const char* relativePathToWrite)
//----------------------------------------------------------------------------------------
{
nsFilePath myTextFilePath(relativePathToWrite, PR_TRUE);
const char* pathAsString = (const char*)myTextFilePath;
nsFileSpec mySpec(myTextFilePath);
nsIOFileStream testStream(mySpec, (PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE));
if (!testStream.is_open())
{
mConsole
<< "ERROR: File "
<< pathAsString
<< " could not be opened for input+output"
<< nsEndl;
return -1;
}
nsPersistentFileDescriptor myPersistent(mySpec);
mConsole
<< "Writing persistent file data " << pathAsString << nsEndl << nsEndl;
testStream.seek(0); // check that the seek compiles
testStream << myPersistent;
testStream.seek(0);
nsPersistentFileDescriptor mySecondPersistent;
testStream >> mySecondPersistent;
mySpec = mySecondPersistent;
#ifdef XP_MAC
if (mySpec.Error())
{
Failed();
return -1;
}
#endif
if (!mySpec.Exists())
{
Failed();
return -1;
}
Passed();
return 0;
}
//----------------------------------------------------------------------------------------
int FilesTest::InputStream(const char* relativePath)
//----------------------------------------------------------------------------------------
{
nsFilePath myTextFilePath(relativePath, PR_TRUE);
nsFilePath myTextFilePath(relativePath, true);
const char* pathAsString = (const char*)myTextFilePath;
mConsole << "READING BACK DATA FROM " << pathAsString << nsEndl << nsEndl;
nsFileSpec mySpec(myTextFilePath);
nsInputFileStream testStream2(mySpec);
nsInputFileStream testStream2(myTextFilePath);
if (!testStream2.is_open())
{
mConsole
@@ -278,12 +197,12 @@ int FilesTest::InputStream(const char* relativePath)
//----------------------------------------------------------------------------------------
int FilesTest::Parent(
const char* relativePath,
nsFileSpec& outParent)
nsNativeFileSpec& outParent)
//----------------------------------------------------------------------------------------
{
nsFilePath myTextFilePath(relativePath, PR_TRUE);
nsFilePath myTextFilePath(relativePath, true);
const char* pathAsString = (const char*)myTextFilePath;
nsFileSpec mySpec(myTextFilePath);
nsNativeFileSpec mySpec(myTextFilePath);
mySpec.GetParent(outParent);
nsFilePath parentPath(outParent);
@@ -298,7 +217,7 @@ int FilesTest::Parent(
}
//----------------------------------------------------------------------------------------
int FilesTest::Delete(nsFileSpec& victim)
int FilesTest::Delete(nsNativeFileSpec& victim)
//----------------------------------------------------------------------------------------
{
// - Test of non-recursive delete
@@ -309,7 +228,7 @@ int FilesTest::Delete(nsFileSpec& victim)
<< "\n\t" << (const char*)victimPath
<< "\n without recursive option (should fail)"
<< nsEndl;
victim.Delete(PR_FALSE);
victim.Delete(false);
if (victim.Exists())
Passed();
else
@@ -331,7 +250,7 @@ int FilesTest::Delete(nsFileSpec& victim)
<< "\n\t" << (const char*)victimPath
<< "\n with recursive option"
<< nsEndl;
victim.Delete(PR_TRUE);
victim.Delete(true);
if (victim.Exists())
{
mConsole
@@ -347,7 +266,7 @@ int FilesTest::Delete(nsFileSpec& victim)
}
//----------------------------------------------------------------------------------------
int FilesTest::CreateDirectory(nsFileSpec& dirSpec)
int FilesTest::CreateDirectory(nsNativeFileSpec& dirSpec)
//----------------------------------------------------------------------------------------
{
nsFilePath dirPath(dirSpec);
@@ -364,32 +283,32 @@ int FilesTest::CreateDirectory(nsFileSpec& dirSpec)
Failed();
return -1;
}
dirSpec.Delete(PR_TRUE);
dirSpec.Delete(true);
return 0;
}
//----------------------------------------------------------------------------------------
int FilesTest::IterateDirectoryChildren(nsFileSpec& startChild)
int FilesTest::IterateDirectoryChildren(nsNativeFileSpec& startChild)
//----------------------------------------------------------------------------------------
{
// - Test of directory iterator
nsFileSpec grandparent;
nsNativeFileSpec grandparent;
startChild.GetParent(grandparent); // should be the original default directory.
nsFilePath grandparentPath(grandparent);
mConsole << "Forwards listing of " << (const char*)grandparentPath << ":" << nsEndl;
for (nsDirectoryIterator i(grandparent, +1); i.Exists(); i++)
for (nsDirectoryIterator i(grandparent, +1); i; i++)
{
char* itemName = ((nsFileSpec&)i).GetLeafName();
char* itemName = ((nsNativeFileSpec&)i).GetLeafName();
mConsole << '\t' << itemName << nsEndl;
delete [] itemName;
}
mConsole << "Backwards listing of " << (const char*)grandparentPath << ":" << nsEndl;
for (nsDirectoryIterator j(grandparent, -1); j.Exists(); j--)
for (nsDirectoryIterator j(grandparent, -1); j; j--)
{
char* itemName = ((nsFileSpec&)j).GetLeafName();
char* itemName = ((nsNativeFileSpec&)j).GetLeafName();
mConsole << '\t' << itemName << nsEndl;
delete [] itemName;
}
@@ -402,7 +321,7 @@ int FilesTest::CanonicalPath(
const char* relativePath)
//----------------------------------------------------------------------------------------
{
nsFilePath myTextFilePath(relativePath, PR_TRUE);
nsFilePath myTextFilePath(relativePath, true);
const char* pathAsString = (const char*)myTextFilePath;
if (*pathAsString != '/')
{
@@ -418,110 +337,6 @@ int FilesTest::CanonicalPath(
return 0;
}
//----------------------------------------------------------------------------------------
int FilesTest::Copy(const char* file, const char* dir)
//----------------------------------------------------------------------------------------
{
nsFileSpec dirPath(dir, PR_TRUE);
dirPath.CreateDirectory();
if (! dirPath.Exists())
{
Failed();
return -1;
}
nsFileSpec mySpec(file, PR_TRUE); // relative path.
{
nsIOFileStream testStream(mySpec); // creates the file
// Scope ends here, file gets closed
}
nsFileSpec filePath(file);
if (! filePath.Exists())
{
Failed();
return -1;
}
nsresult error = filePath.Copy(dirPath);
dirPath += filePath.GetLeafName();
if (! dirPath.Exists() || ! filePath.Exists() || NS_FAILED(error))
{
Failed();
return -1;
}
Passed();
return 0;
}
//----------------------------------------------------------------------------------------
int FilesTest::Move(const char* file, const char* dir)
//----------------------------------------------------------------------------------------
{
nsFileSpec dirPath(dir, PR_TRUE);
dirPath.CreateDirectory();
if (! dirPath.Exists())
{
Failed();
return -1;
}
nsFileSpec srcSpec(file, PR_TRUE); // relative path.
{
nsIOFileStream testStream(srcSpec); // creates the file
// file gets closed here because scope ends here.
};
if (! srcSpec.Exists())
{
Failed();
return -1;
}
nsresult error = srcSpec.Move(dirPath);
dirPath += srcSpec.GetLeafName();
if (! dirPath.Exists() || srcSpec.Exists() || NS_FAILED(error))
{
Failed();
return -1;
}
Passed();
return 0;
}
//----------------------------------------------------------------------------------------
int FilesTest::Execute(const char* appName, const char* args)
//----------------------------------------------------------------------------------------
{
nsFileSpec appPath(appName, PR_FALSE);
if (!appPath.Exists())
{
Failed();
return -1;
}
nsresult error = appPath.Execute(args);
if (NS_FAILED(error))
{
Failed();
return -1;
}
Passed();
return 0;
}
//----------------------------------------------------------------------------------------
int FilesTest::RunAllTests()
// For use with DEBUG defined.
@@ -556,7 +371,7 @@ int FilesTest::RunAllTests()
return -1;
Banner("Parent");
nsFileSpec parent;
nsNativeFileSpec parent;
if (Parent("mumble/iotest.txt", parent) != 0)
return -1;
@@ -572,36 +387,6 @@ int FilesTest::RunAllTests()
if (IterateDirectoryChildren(parent) != 0)
return -1;
Banner("Copy");
if (Copy("mumble/copyfile.txt", "mumble/copy") != 0)
return -1;
Banner("Move");
if (Move("mumble/moveFile.txt", "mumble/move") != 0)
return -1;
Banner("Execute");
#ifdef XP_MAC
// This path is hard-coded to test on jrm's machine. Finding an app
// on an arbitrary Macintosh would cost more trouble than it's worth.
// Change path to suit.
if NS_FAILED(Execute("/Projects/Nav45_BRANCH/ns/cmd/macfe/"\
"projects/client45/Client45PPC", ""))
#elif XP_PC
if NS_FAILED(Execute("c:\\windows\\notepad.exe", ""))
#else
if NS_FAILED(Execute("/bin/ls", "/"))
#endif
return -1;
Banner("Persistence");
if (Persistence("mumble/filedesc.dat") != 0)
return -1;
Banner("Delete again (to clean up our mess)");
if (Delete(parent) != 0)
return -1;
return 0;
}
@@ -610,6 +395,7 @@ int main()
// For use with DEBUG defined.
//----------------------------------------------------------------------------------------
{
FilesTest tester;
return tester.RunAllTests();
} // main

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 \
-ljs \
-lxp \
-lraptorbase \
-lxpcom \
-lreg \
$(ZLIB_LIBS) \
$(NSPR_LIBS) \
$(NULL)

View File

@@ -31,43 +31,23 @@
#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[])
{
nsRepository::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL,
nsRepository::RegisterFactory(kNetServiceCID, NETLIB_DLL, PR_FALSE,
PR_FALSE);
nsRepository::RegisterFactory(kEventQueueServiceCID, XPCOM_DLL,
PR_FALSE, PR_FALSE);
nsRepository::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,

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
@@ -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,109 +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_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_READ_MYCONFIG() - Read in 'myconfig.sh' file
AC_DEFUN(MOZ_READ_MYCONFIG,
[AC_REQUIRE([AC_INIT_BINSH])dnl
# Read in 'myconfig.sh' script to set the initial options.
# See the load-myconfig.sh script for more details.
_topsrcdir=`dirname [$]0`
_load_myconfig=$_topsrcdir/build/autoconf/load-myconfig.sh
if test "$MOZ_MYCONFIG"; then
. $_load_myconfig
elif test -f myconfig.sh; then
MOZ_MYCONFIG=myconfig.sh
. $_load_myconfig
elif test -f $_topsrcdir/myconfig.sh; then
MOZ_MYCONFIG=$_topsrcdir/myconfig.sh
. $_load_myconfig
fi])
dnl This gets inserted at the top of the configure script
MOZ_READ_MYCONFIG

View File

@@ -1,81 +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-myconfig.sh - Loads options from myconfig.sh onto configure's
# command-line. The myconfig.sh is searched for in the following
# order: $MOZ_MYCONFIG, $objdir/myconfig.sh, $topsrcdir/myconfig.sh.
#
# The options from myconfig.sh are inserted into the command-line
# before the real command-line options. This way the real options
# will override any myconfig.sh options.
#
# myconfig.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 myconfig.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;'`
config_file_options="$config_file_options $_opt"
done
}
ac_echo_options() {
echo "Adding options from `pwd`/myconfig.sh:"
eval "set -- $config_file_options"
for opt
do
echo " $opt"
done
}
#
# Define load the options
#
ac_options=
config_file_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
. $MOZ_MYCONFIG
ac_echo_options 1>&2
eval "set -- $config_file_options $ac_options"

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

@@ -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,17 +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:unicharutil:public:MANIFEST", "$distdirectory:unicharutil");
InstallFromManifest(":mozilla:intl:locale:public:MANIFEST", "$distdirectory:locale:");
#STRRES
InstallFromManifest(":mozilla:intl:strres:public:MANIFEST", "$distdirectory:strres:");
#JPEG
InstallFromManifest(":mozilla:jpeg:MANIFEST", "$distdirectory:jpeg:");
@@ -215,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:");
@@ -278,12 +265,10 @@ sub BuildDist()
#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:");
@@ -303,14 +288,12 @@ 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:");
@@ -344,10 +327,6 @@ sub BuildDist()
}
}
# 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");
}
@@ -459,10 +438,6 @@ sub BuildCommonProjects()
BuildOneProject(":mozilla:js:macbuild:LiveConnect.mcp", "LiveConnect$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:modules:zlib:macbuild:zlib.mcp", "zlib$D.shlb", "zlib.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:caps:macbuild:Caps.mcp", "Caps$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:modules:oji:macbuild:oji.mcp", "oji$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:modules:libpref:macbuild:libpref.mcp", "libpref$D.shlb", "libpref.toc", 1, $main::ALIAS_SYM_FILES);
@@ -473,15 +448,6 @@ sub BuildCommonProjects()
BuildOneProject(":mozilla:intl:uconv:macbuild:ucvlatin.mcp", "ucvlatin$D.shlb", "uconvlatin.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:intl:uconv:macbuild:ucvja.mcp", "ucvja$D.shlb", "ucvja.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:intl:unicharutil:macbuild:unicharutil.mcp", "unicharutil$D.shlb", "unicharutil.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:intl:locale:macbuild:locale.mcp", "nslocale$D.shlb", "nslocale.toc", 1, $main::ALIAS_SYM_FILES);
BuildOneProject(":mozilla:intl:strres:macbuild:strres.mcp", "strres$D.shlb", "strres.toc", 1, $main::ALIAS_SYM_FILES);
#// removing powerplant - long live powerplant
# BuildOneProject(":mozilla:lib:mac:PowerPlant:PowerPlant.mcp", "PowerPlant$D.shlb", "", 1, $main::ALIAS_SYM_FILES);
@@ -495,8 +461,7 @@ sub BuildCommonProjects()
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);
BuildOneProject(":mozilla:rdf:macbuild:rdf.mcp", "rdf$D.shlb", "rdf.toc", 1, $main::ALIAS_SYM_FILES);
}
@@ -543,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");
@@ -567,8 +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");
}
@@ -624,11 +586,7 @@ sub BuildLayoutProjects()
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);
BuildOneProject(":mozilla:webshell:embed:mac:RaptorShell.mcp", "RaptorShell$D.shlb", "RaptorShell.toc", 1, $main::ALIAS_SYM_FILES);
#// 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);
}
@@ -670,6 +628,7 @@ sub BuildViewerProjects()
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);
}
@@ -688,8 +647,6 @@ sub BuildXPAppProjects()
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);
BuildOneProject(":mozilla:xpfe:bootstrap:macbuild:apprunner.mcp", "apprunner$D", "apprunner.toc", 0, 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 = 0;
$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.

View File

@@ -267,5 +267,5 @@ public:
0x307f, \
0x11d2, \
{0x97, 0xf0, 0x00, 0x80, 0x5f, 0x8a, 0x28, 0xd0} \
}
};
#endif // nsICapsManager_h___

View File

@@ -18,6 +18,7 @@
#include "prtypes.h"
#include "nspr.h"
#include "prmem.h"
#include "prmon.h"
#include "prlog.h"

View File

@@ -16,6 +16,7 @@
* Reserved.
*/
#include "prtypes.h"
#include "nspr.h"
#include "prmem.h"
#include "prmon.h"
#include "prlog.h"
@@ -39,11 +40,7 @@ nsIFactory *nsCCapsManagerFactory::m_pNSIFactory = NULL;
+++++++++++++++++++++++++++++++++++++++++++++++++*/
extern "C" NS_EXPORT nsresult
NSGetFactory(nsISupports* servMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
NSGetFactory(const nsCID &aClass, nsISupports* servMgr, nsIFactory **aFactory)
{
if (!aClass.Equals(kCCapsManagerCID)) {
@@ -58,7 +55,7 @@ NSGetFactory(nsISupports* servMgr,
}
extern "C" NS_EXPORT PRBool
NSCanUnload(nsISupports* serviceMgr)
NSCanUnload(void)
{
return PR_FALSE;
}
@@ -137,8 +134,8 @@ nsCCapsManagerFactory::nsCCapsManagerFactory(void)
if ( (err == NS_OK) && (m_pNSIFactory != NULL) )
{
NS_DEFINE_CID(kCCapsManagerCID, NS_CCAPSMANAGER_CID);
nsRepository::RegisterFactory(kCCapsManagerCID, 0, 0,
m_pNSIFactory, PR_FALSE);
nsRepository::RegisterFactory(kCCapsManagerCID, m_pNSIFactory,
PR_FALSE);
}
}

View File

@@ -18,6 +18,7 @@
#include "prtypes.h"
#include "nspr.h"
#include "prmem.h"
#include "prmon.h"
#include "prlog.h"

View File

@@ -729,6 +729,7 @@ PRInt32 nsPrincipal::computeHashCode(void)
char * nsPrincipal::saveCert(void)
{
int result;
if (itsType == nsPrincipalType_CertChain) {
return NULL;
}
@@ -737,7 +738,6 @@ char * nsPrincipal::saveCert(void)
}
#ifdef MOZ_SECURITY
int result;
result = SOB_stash_cert((ZIG *)itsZig, itsKeyLen, itsKey);
if (result < 0) {
return SOB_get_error(result);
@@ -751,6 +751,8 @@ char * nsPrincipal::saveCert(void)
char *
nsPrincipal::getCertAttribute(int attrib)
{
void *result;
unsigned long length;
char *attrStr = "Untrusted certificate (unknown attributes)";
ZIG *zig = NULL;
@@ -797,8 +799,6 @@ nsPrincipal::getCertAttribute(int attrib)
}
#ifdef MOZ_SECURITY
void *result;
unsigned long length;
if (SOB_cert_attribute(attrib, zig,
itsKeyLen, itsKey,
&result, &length) < 0) {

View File

@@ -1277,10 +1277,10 @@ nsPrivilegeManager::getClassPrincipalsFromStack(void* context, PRInt32 callerDep
int depth = 0;
struct NSJSJavaFrameWrapper *wrapper = NULL;
if (nsCapsNewNSJSJavaFrameWrapperCallback == NULL) {
if (*nsCapsNewNSJSJavaFrameWrapperCallback == NULL) {
return NULL;
}
wrapper = (*nsCapsNewNSJSJavaFrameWrapperCallback)(context);
wrapper = (nsCapsNewNSJSJavaFrameWrapperCallback)(context);
if (wrapper == NULL)
return NULL;

View File

@@ -38,8 +38,8 @@ extern int CAPS_TARGET_HELP_URL;
//
char * JavaSecUI_targetRiskStr(int risk)
{
#ifdef XXX
char * str;
#ifdef XXX
if (risk <= nsRiskType_LowRisk) {
str = XP_GetString(CAPS_TARGET_RISK_STR_LOW);
} else if (risk <= nsRiskType_MediumRisk) {

View File

@@ -310,7 +310,7 @@ static PRBool
nsZipFindEnd(ns_zip_t *zip, char *endbuf)
{
char buf[INBUFSIZ+SIGSIZ], *bp;
PRUint32 len, off, mark;
PRInt32 len, off, mark;
/* Need to search backwards from end of file */
if ((len = PR_Seek(zip->fd, 0, SEEK_END)) == -1) {

View File

@@ -86,7 +86,7 @@ pull_lizard:
$(CVSCO_LIZARD) $(MOZ_TOP)/lib/liblayer
$(CVSCO_LIZARD) $(MOZ_TOP)/modules/zlib
$(CVSCO_LIZARD) $(MOZ_TOP)/modules/libutil
$(CVSCO_LIZARD) $(MOZ_TOP)/nsprpub
$(CVSCO_TAG) -r NSPRPUB_RELEASE_3_0 $(MOZ_TOP)/nsprpub
$(CVSCO_LIZARD) $(MOZ_TOP)/sun-java
$(CVSCO_LIZARD) $(MOZ_TOP)/nav-java
$(CVSCO_LIZARD) $(MOZ_TOP)/js
@@ -146,12 +146,8 @@ clobber_nglayout:
@cd $(MOZ_SRC)\mozilla\.
nmake -f nglayout.mak clobber_all $(NGLAYOUT_ENV_VARS)
build_all: build_seamonkey build_apprunner
build_all: build_seamonkey
build_seamonkey:
@cd $(MOZ_SRC)\mozilla\.
nmake -f nglayout.mak all
build_apprunner:
@cd $(MOZ_SRC)\mozilla\xpfe\.
nmake -f makefile.win

View File

@@ -0,0 +1,130 @@
/* -*- 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 "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.
*/
//
// CIconCache.h
// Mike Pinkerton, Netscape Communications
//
// Contains the implementation of the CImageCache class which is a small cache of
// images which the FE can pull from with a low overhead. It's good for things
// such as using images for icons in the chrome. Note that this is very
// different from the XP image cache.
//
// The filename is old, owing back to the original name for this class, CIconCache
//
#pragma once
#include <map>
#include <string>
#include "CIconContext.h"
#include "il_types.h"
#include "mimages.h"
//
// class ImageCacheData
//
// Contains all the relevant data for an image loaded from a url (not an FE icon). The
// context controls the loading and notification of when the image has been loaded
// and keeps copies of the FE pixmap data so when imageLib cleans house, we're still ok.
//
class ImageCacheData : public LBroadcaster {
public:
ImageCacheData ( const string & inURL ) ;
~ImageCacheData ( ) ;
// Hold on tight to whatever we need to draw, making copies if necessary.
void CacheThese ( IL_Pixmap* inImage, IL_Pixmap* inMask ) ;
CIconContext* IconContext ( ) const { return mContext; } ;
void IconContextHasGoneAway ( ) { mContext = NULL; } ;
bool ImageAvailable ( ) { return mImage != NULL; } ;
NS_PixMap* Image ( ) const { return mImage; }
NS_PixMap* Mask ( ) const { return mMask; }
private:
// declare these as private so no one can do them.
ImageCacheData ( const ImageCacheData & ) ;
ImageCacheData & operator= ( const ImageCacheData & ) ;
NS_PixMap* mImage;
NS_PixMap* mMask;
CIconContext* mContext;
}; // struct ImageCacheData
//
// class CImageCache
//
// There should only be one of these in the entire application. Users make a request
// by asking the cache for a particular URL. If the URL is not loaded, a new icon context
// will be created and the caller will be placed on a list of listeners for when that
// image is ready to draw. If the image has already been loaded, the caller will either
// be placed on that listener list (for animating images) or be given the data directly
// (for static images).
//
class CImageCache : public LListener
{
public:
enum ELoadResult { kDataPresent, kPutOnWaitingList, kEmptyURL } ;
CImageCache ( ) ;
virtual ~CImageCache ( ) ;
// Make a request for an icon. Will start loading if not present. If an
// empty string is passed in, this will return |kEmptyURL| and nothing
// will be loaded.
ELoadResult RequestIcon ( const string & inURL, const LListener* inClient ) ;
// For images that are already loaded (RequestIcon() returned |kDataPresent|,
// get the data.
void FetchImageData ( const string & inURL, NS_PixMap** outImage, NS_PixMap** outMask ) ;
// Housecleaning. When a static image is finished, the context should go away
// but the data should remain.
void ContextFinished ( const MWContext* inContext ) ;
// a view might be going away before an image is finished loading. If that is
// the case, it needs to be removed from the context's listener list so we don't
// go telling dead objects their image has arrived.
void ListenerGoingAway ( const string & inURL, LListener* inObjectGoingAway ) ;
private:
// declare these private so no one can make a copy of the cache
CImageCache ( const CImageCache & ) ;
CImageCache & operator= ( const CImageCache & ) ;
void ListenToMessage ( MessageT inMessage, void* inData ) ;
// clean out the cache when it gets too big.
void Flush() ;
map<string, ImageCacheData*> mCache;
}; // class CImageCache
// global declaration of our icon cache
CImageCache& gImageCache ( ) ;

View File

@@ -1,3 +1,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
@@ -13,7 +14,9 @@
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
# This is a list of local files which get copied to the mozilla:dist:dom directory
#
nsJSUtils.h
Evaluate % = ("{{SourceFile}}" =~ /(Å:)¨0Å/)
MakeStub "{{SourceFile}}" -o "{{¨0}}::::dist:client_stubs:NavigatorStubs" ¶
-fragname Navigator ¶
-vercur 400 -verdef 400 -verimp 400

View File

@@ -1,4 +1,3 @@
#!nmake
#
# 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
@@ -14,9 +13,10 @@
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
DEPTH=..\..
DIRS=public src
include <$(DEPTH)\config\rules.mak>
# export debugging functions
#{code}
NOT_NULL
XP_TraceInit
FE_Trace

View File

@@ -13,9 +13,10 @@
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
DEPTH=..\..\..\..
IGNORE_MANIFEST=1
DIRS=win32
Evaluate % = ("{{SourceFile}}" =~ /(Å:)¨0Å/)
include <$(DEPTH)\config\rules.mak>
MakeStub "{{SourceFile}}" -o "{{¨0}}::::dist:client_stubs:NavigatorDebugExtras" ¶
-fragname Navigator ¶
-vercur 400 -verdef 400 -verimp 400

Binary file not shown.

View File

@@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
/* -*- 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 "NPL"); you may not use this file except in
@@ -16,18 +16,18 @@
* Reserved.
*/
#include "nsIBaseStream.idl"
[object, uuid(022396f0-93b5-11d1-895b-006008911b81)]
interface nsIInputStream : nsIBaseStream {
unsigned long GetLength();
/* this is really an out char buf, but I don't know how to express
* that in IDL */
unsigned long Read(in string aBuf,
in unsigned long aOffset,
in unsigned long aCount,
out unsigned long aReadCount);
};
/*
The one and only job of this project is to provide dummy
libraries for the main project, when you are doing a build
with some components turned off.
For example, if you compile MOZ_LITE, there is no editor.
But to avoid having to have multiple targets in the final
project, we just provide a stub library from here, to
keep the IDE happy.
There will be one target for each dummy library that we
need.
*/
void NuthinToDo(void) {}

Binary file not shown.

View File

@@ -1,5 +1,5 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
/* -*- 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 "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
@@ -16,35 +16,50 @@
* Reserved.
*/
#ifndef nsSupportsArrayEnumerator_h___
#define nsSupportsArrayEnumerator_h___
/* CAutoPtr.h */
#include "nsIEnumerator.h"
class nsISupportsArray;
#ifndef CAutoPtr_H
#define CAutoPtr_H
#pragma once
class NS_COM nsSupportsArrayEnumerator : public nsIBidirectionalEnumerator {
public:
NS_DECL_ISUPPORTS
template<class T>
class CAutoPtr
{
public:
CAutoPtr(T* p = 0) : p_(p) { }
CAutoPtr(const CAutoPtr& r) : p_(r.release()) { }
~CAutoPtr() { delete p_; }
CAutoPtr& operator = (const CAutoPtr& r) {
if ((void *)&r != (void *) this) {
delete p_;
p_ = r.release();
}
return *this;
}
nsSupportsArrayEnumerator(nsISupportsArray* array);
virtual ~nsSupportsArrayEnumerator();
// nsIEnumerator methods:
NS_IMETHOD First();
NS_IMETHOD Next();
NS_IMETHOD CurrentItem(nsISupports **aItem);
NS_IMETHOD IsDone();
// nsIBidirectionalEnumerator methods:
NS_IMETHOD Last();
NS_IMETHOD Prev();
protected:
nsISupportsArray* mArray;
PRInt32 mCursor;
T& operator*(void) const{ return *p_; }
T* operator->(void) const { return p_; }
T* get(void) const { return p_; }
void reset(T* p = 0) {
delete p_;
p_ = p;
}
T* release(void) const {
T* old = p_;
const_cast<CAutoPtr*>(this)->p_ = 0;
return old;
}
private:
T* p_;
};
#endif // __nsSupportsArrayEnumerator_h
#endif

View File

@@ -0,0 +1,77 @@
/* -*- 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 "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.
*/
/* CAutoPtrXP.h */
#ifndef CAutoPtrXP_H
#define CAutoPtrXP_H
#pragma once
#include "xp_mem.h"
template<class T>
class CAutoPtrXP
{
public:
CAutoPtrXP(T* p = 0) : p_(p) { }
CAutoPtrXP(const CAutoPtrXP& r) : p_(r.release()) { }
~CAutoPtrXP() {
if (p_)
{
XP_FREE(p_);
}
}
CAutoPtrXP& operator = (const CAutoPtrXP& r) {
if ((void *)&r != (void *) this) {
if (p_)
{
XP_FREE(p_);
}
p_ = r.release();
}
return *this;
}
T& operator*(void) const{ return *p_; }
T* operator->(void) const { return p_; }
T* get(void) const { return p_; }
void reset(T* p = 0) {
if (p_)
{
XP_FREE(p_);
}
p_ = p;
}
T* release() const {
T* old = p_;
const_cast<CAutoPtrXP*>(this)->p_ = 0;
return old;
}
private:
T* p_;
};
#endif

View File

@@ -0,0 +1,47 @@
/* -*- 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 "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.
*/
// ===========================================================================
// CDefaultFontFontSwitcher.cp
// ===========================================================================
//
// Authror: Frank Tang ftang@netscape.com
#include "CDefaultFontFontSwitcher.h"
#include "uintl.h"
INTL_Encoding_ID CDefaultFontFontSwitcher::gEncodingOfDefaultFont = 0;
CDefaultFontFontSwitcher::CDefaultFontFontSwitcher(UFontSwitcher* delegate)
{
GrafPtr port;
::GetPort(&port);
mDefaultFont = port->txFont;
if(0 == gEncodingOfDefaultFont)
{
gEncodingOfDefaultFont = ScriptToEncoding(::GetScriptManagerVariable( smSysScript ) );
}
mDelegate = delegate;
}
void CDefaultFontFontSwitcher::EncodingTextFont(INTL_Encoding_ID encoding)
{
if(gEncodingOfDefaultFont == encoding)
::TextFont(mDefaultFont);
else
mDelegate->EncodingTextFont(encoding);
}

View File

@@ -0,0 +1,42 @@
/* -*- 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 "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.
*/
// ===========================================================================
// CDefaultFontFontSwitcher.h
// ===========================================================================
//
// Authror: Frank Tang ftang@netscape.com
/*-----------------------------------------------------------------------------
CDefaultFontFontSwitcher
Class know how to switch font depend on CPrefs:CCharSet
*/
#pragma once
#include "UPropFontSwitcher.h"
class CDefaultFontFontSwitcher : public UFontSwitcher {
public:
virtual void EncodingTextFont(INTL_Encoding_ID encoding);
CDefaultFontFontSwitcher(UFontSwitcher* delegate);
void RestoreDefaultFont() {::TextFont(mDefaultFont); }
private:
static INTL_Encoding_ID gEncodingOfDefaultFont;
UFontSwitcher* mDelegate;
short mDefaultFont;
};

View File

@@ -0,0 +1,50 @@
/* -*- 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 "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.
*/
// CLibMsgPeriodical.cp
#include "CLibMsgPeriodical.h"
#include "msgcom.h"
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// ¥¥¥
// ¥ Class CLibMsgPeriodical
// ¥¥¥
//
// This is a subclass of LPeriodical which calls the new libmsg init, exit,
// and idle routines.
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
CLibMsgPeriodical::CLibMsgPeriodical() :
LPeriodical()
{
MSG_InitMsgLib();
/* use less memory! */
MSG_SetDBCacheSize ( 512 * 1024L );
}
CLibMsgPeriodical::~CLibMsgPeriodical()
{
MSG_ShutdownMsgLib();
}
void CLibMsgPeriodical::SpendTime(const EventRecord& /* inMacEvent */)
{
MSG_OnIdle();
}

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