Mercurial > hg > octave-nkf
comparison liboctave/system/file-ops.cc @ 15271:648dabbb4c6b
build: Refactor liboctave into multiple subdirectories. Move libcruft into liboctave.
* array/Array-C.cc, array/Array-b.cc, array/Array-ch.cc, array/Array-d.cc,
array/Array-f.cc, array/Array-fC.cc, array/Array-i.cc, array/Array-idx-vec.cc,
array/Array-s.cc, array/Array-str.cc, array/Array-util.cc, array/Array-util.h,
array/Array-voidp.cc, array/Array.cc, array/Array.h, array/Array2.h,
array/Array3.h, array/ArrayN.h, array/CColVector.cc, array/CColVector.h,
array/CDiagMatrix.cc, array/CDiagMatrix.h, array/CMatrix.cc, array/CMatrix.h,
array/CNDArray.cc, array/CNDArray.h, array/CRowVector.cc, array/CRowVector.h,
array/CSparse.cc, array/CSparse.h, array/DiagArray2.cc, array/DiagArray2.h,
array/MArray-C.cc, array/MArray-d.cc, array/MArray-decl.h, array/MArray-defs.h,
array/MArray-f.cc, array/MArray-fC.cc, array/MArray-i.cc, array/MArray-s.cc,
array/MArray.cc, array/MArray.h, array/MArray2.h, array/MArrayN.h,
array/MDiagArray2.cc, array/MDiagArray2.h, array/MSparse-C.cc,
array/MSparse-d.cc, array/MSparse-defs.h, array/MSparse.cc, array/MSparse.h,
array/Matrix.h, array/MatrixType.cc, array/MatrixType.h, array/PermMatrix.cc,
array/PermMatrix.h, array/Range.cc, array/Range.h, array/Sparse-C.cc,
array/Sparse-b.cc, array/Sparse-d.cc, array/Sparse.cc, array/Sparse.h,
array/boolMatrix.cc, array/boolMatrix.h, array/boolNDArray.cc,
array/boolNDArray.h, array/boolSparse.cc, array/boolSparse.h,
array/chMatrix.cc, array/chMatrix.h, array/chNDArray.cc, array/chNDArray.h,
array/dColVector.cc, array/dColVector.h, array/dDiagMatrix.cc,
array/dDiagMatrix.h, array/dMatrix.cc, array/dMatrix.h, array/dNDArray.cc,
array/dNDArray.h, array/dRowVector.cc, array/dRowVector.h, array/dSparse.cc,
array/dSparse.h, array/dim-vector.cc, array/dim-vector.h, array/fCColVector.cc,
array/fCColVector.h, array/fCDiagMatrix.cc, array/fCDiagMatrix.h,
array/fCMatrix.cc, array/fCMatrix.h, array/fCNDArray.cc, array/fCNDArray.h,
array/fCRowVector.cc, array/fCRowVector.h, array/fColVector.cc,
array/fColVector.h, array/fDiagMatrix.cc, array/fDiagMatrix.h,
array/fMatrix.cc, array/fMatrix.h, array/fNDArray.cc, array/fNDArray.h,
array/fRowVector.cc, array/fRowVector.h, array/idx-vector.cc,
array/idx-vector.h, array/int16NDArray.cc, array/int16NDArray.h,
array/int32NDArray.cc, array/int32NDArray.h, array/int64NDArray.cc,
array/int64NDArray.h, array/int8NDArray.cc, array/int8NDArray.h,
array/intNDArray.cc, array/intNDArray.h, array/module.mk,
array/uint16NDArray.cc, array/uint16NDArray.h, array/uint32NDArray.cc,
array/uint32NDArray.h, array/uint64NDArray.cc, array/uint64NDArray.h,
array/uint8NDArray.cc, array/uint8NDArray.h:
Moved from liboctave dir to array subdirectory.
* cruft/Makefile.am, cruft/amos/README, cruft/amos/cacai.f, cruft/amos/cacon.f,
cruft/amos/cairy.f, cruft/amos/casyi.f, cruft/amos/cbesh.f, cruft/amos/cbesi.f,
cruft/amos/cbesj.f, cruft/amos/cbesk.f, cruft/amos/cbesy.f, cruft/amos/cbinu.f,
cruft/amos/cbiry.f, cruft/amos/cbknu.f, cruft/amos/cbuni.f, cruft/amos/cbunk.f,
cruft/amos/ckscl.f, cruft/amos/cmlri.f, cruft/amos/crati.f, cruft/amos/cs1s2.f,
cruft/amos/cseri.f, cruft/amos/cshch.f, cruft/amos/cuchk.f, cruft/amos/cunhj.f,
cruft/amos/cuni1.f, cruft/amos/cuni2.f, cruft/amos/cunik.f, cruft/amos/cunk1.f,
cruft/amos/cunk2.f, cruft/amos/cuoik.f, cruft/amos/cwrsk.f,
cruft/amos/dgamln.f, cruft/amos/gamln.f, cruft/amos/module.mk,
cruft/amos/xzabs.f, cruft/amos/xzexp.f, cruft/amos/xzlog.f,
cruft/amos/xzsqrt.f, cruft/amos/zacai.f, cruft/amos/zacon.f,
cruft/amos/zairy.f, cruft/amos/zasyi.f, cruft/amos/zbesh.f, cruft/amos/zbesi.f,
cruft/amos/zbesj.f, cruft/amos/zbesk.f, cruft/amos/zbesy.f, cruft/amos/zbinu.f,
cruft/amos/zbiry.f, cruft/amos/zbknu.f, cruft/amos/zbuni.f, cruft/amos/zbunk.f,
cruft/amos/zdiv.f, cruft/amos/zkscl.f, cruft/amos/zmlri.f, cruft/amos/zmlt.f,
cruft/amos/zrati.f, cruft/amos/zs1s2.f, cruft/amos/zseri.f, cruft/amos/zshch.f,
cruft/amos/zuchk.f, cruft/amos/zunhj.f, cruft/amos/zuni1.f, cruft/amos/zuni2.f,
cruft/amos/zunik.f, cruft/amos/zunk1.f, cruft/amos/zunk2.f, cruft/amos/zuoik.f,
cruft/amos/zwrsk.f, cruft/blas-xtra/cconv2.f, cruft/blas-xtra/cdotc3.f,
cruft/blas-xtra/cmatm3.f, cruft/blas-xtra/csconv2.f, cruft/blas-xtra/dconv2.f,
cruft/blas-xtra/ddot3.f, cruft/blas-xtra/dmatm3.f, cruft/blas-xtra/module.mk,
cruft/blas-xtra/sconv2.f, cruft/blas-xtra/sdot3.f, cruft/blas-xtra/smatm3.f,
cruft/blas-xtra/xcdotc.f, cruft/blas-xtra/xcdotu.f, cruft/blas-xtra/xddot.f,
cruft/blas-xtra/xdnrm2.f, cruft/blas-xtra/xdznrm2.f, cruft/blas-xtra/xerbla.f,
cruft/blas-xtra/xscnrm2.f, cruft/blas-xtra/xsdot.f, cruft/blas-xtra/xsnrm2.f,
cruft/blas-xtra/xzdotc.f, cruft/blas-xtra/xzdotu.f, cruft/blas-xtra/zconv2.f,
cruft/blas-xtra/zdconv2.f, cruft/blas-xtra/zdotc3.f, cruft/blas-xtra/zmatm3.f,
cruft/daspk/datv.f, cruft/daspk/dcnst0.f, cruft/daspk/dcnstr.f,
cruft/daspk/ddasic.f, cruft/daspk/ddasid.f, cruft/daspk/ddasik.f,
cruft/daspk/ddaspk.f, cruft/daspk/ddstp.f, cruft/daspk/ddwnrm.f,
cruft/daspk/dfnrmd.f, cruft/daspk/dfnrmk.f, cruft/daspk/dhels.f,
cruft/daspk/dheqr.f, cruft/daspk/dinvwt.f, cruft/daspk/dlinsd.f,
cruft/daspk/dlinsk.f, cruft/daspk/dmatd.f, cruft/daspk/dnedd.f,
cruft/daspk/dnedk.f, cruft/daspk/dnsd.f, cruft/daspk/dnsid.f,
cruft/daspk/dnsik.f, cruft/daspk/dnsk.f, cruft/daspk/dorth.f,
cruft/daspk/dslvd.f, cruft/daspk/dslvk.f, cruft/daspk/dspigm.f,
cruft/daspk/dyypnw.f, cruft/daspk/module.mk, cruft/dasrt/ddasrt.f,
cruft/dasrt/drchek.f, cruft/dasrt/droots.f, cruft/dasrt/module.mk,
cruft/dassl/ddaini.f, cruft/dassl/ddajac.f, cruft/dassl/ddanrm.f,
cruft/dassl/ddaslv.f, cruft/dassl/ddassl.f, cruft/dassl/ddastp.f,
cruft/dassl/ddatrp.f, cruft/dassl/ddawts.f, cruft/dassl/module.mk,
cruft/fftpack/cfftb.f, cruft/fftpack/cfftb1.f, cruft/fftpack/cfftf.f,
cruft/fftpack/cfftf1.f, cruft/fftpack/cffti.f, cruft/fftpack/cffti1.f,
cruft/fftpack/fftpack.doc, cruft/fftpack/module.mk, cruft/fftpack/passb.f,
cruft/fftpack/passb2.f, cruft/fftpack/passb3.f, cruft/fftpack/passb4.f,
cruft/fftpack/passb5.f, cruft/fftpack/passf.f, cruft/fftpack/passf2.f,
cruft/fftpack/passf3.f, cruft/fftpack/passf4.f, cruft/fftpack/passf5.f,
cruft/fftpack/zfftb.f, cruft/fftpack/zfftb1.f, cruft/fftpack/zfftf.f,
cruft/fftpack/zfftf1.f, cruft/fftpack/zffti.f, cruft/fftpack/zffti1.f,
cruft/fftpack/zpassb.f, cruft/fftpack/zpassb2.f, cruft/fftpack/zpassb3.f,
cruft/fftpack/zpassb4.f, cruft/fftpack/zpassb5.f, cruft/fftpack/zpassf.f,
cruft/fftpack/zpassf2.f, cruft/fftpack/zpassf3.f, cruft/fftpack/zpassf4.f,
cruft/fftpack/zpassf5.f, cruft/lapack-xtra/crsf2csf.f,
cruft/lapack-xtra/module.mk, cruft/lapack-xtra/xclange.f,
cruft/lapack-xtra/xdlamch.f, cruft/lapack-xtra/xdlange.f,
cruft/lapack-xtra/xilaenv.f, cruft/lapack-xtra/xslamch.f,
cruft/lapack-xtra/xslange.f, cruft/lapack-xtra/xzlange.f,
cruft/lapack-xtra/zrsf2csf.f, cruft/link-deps.mk, cruft/misc/blaswrap.c,
cruft/misc/cquit.c, cruft/misc/d1mach-tst.for, cruft/misc/d1mach.f,
cruft/misc/f77-extern.cc, cruft/misc/f77-fcn.c, cruft/misc/f77-fcn.h,
cruft/misc/i1mach.f, cruft/misc/lo-error.c, cruft/misc/lo-error.h,
cruft/misc/module.mk, cruft/misc/quit.cc, cruft/misc/quit.h,
cruft/misc/r1mach.f, cruft/mkf77def.in, cruft/odepack/cfode.f,
cruft/odepack/dlsode.f, cruft/odepack/ewset.f, cruft/odepack/intdy.f,
cruft/odepack/module.mk, cruft/odepack/prepj.f, cruft/odepack/scfode.f,
cruft/odepack/sewset.f, cruft/odepack/sintdy.f, cruft/odepack/slsode.f,
cruft/odepack/solsy.f, cruft/odepack/sprepj.f, cruft/odepack/ssolsy.f,
cruft/odepack/sstode.f, cruft/odepack/stode.f, cruft/odepack/svnorm.f,
cruft/odepack/vnorm.f, cruft/ordered-qz/README, cruft/ordered-qz/dsubsp.f,
cruft/ordered-qz/exchqz.f, cruft/ordered-qz/module.mk,
cruft/ordered-qz/sexchqz.f, cruft/ordered-qz/ssubsp.f, cruft/quadpack/dqagi.f,
cruft/quadpack/dqagie.f, cruft/quadpack/dqagp.f, cruft/quadpack/dqagpe.f,
cruft/quadpack/dqelg.f, cruft/quadpack/dqk15i.f, cruft/quadpack/dqk21.f,
cruft/quadpack/dqpsrt.f, cruft/quadpack/module.mk, cruft/quadpack/qagi.f,
cruft/quadpack/qagie.f, cruft/quadpack/qagp.f, cruft/quadpack/qagpe.f,
cruft/quadpack/qelg.f, cruft/quadpack/qk15i.f, cruft/quadpack/qk21.f,
cruft/quadpack/qpsrt.f, cruft/quadpack/xerror.f, cruft/ranlib/Basegen.doc,
cruft/ranlib/HOWTOGET, cruft/ranlib/README, cruft/ranlib/advnst.f,
cruft/ranlib/genbet.f, cruft/ranlib/genchi.f, cruft/ranlib/genexp.f,
cruft/ranlib/genf.f, cruft/ranlib/gengam.f, cruft/ranlib/genmn.f,
cruft/ranlib/genmul.f, cruft/ranlib/gennch.f, cruft/ranlib/gennf.f,
cruft/ranlib/gennor.f, cruft/ranlib/genprm.f, cruft/ranlib/genunf.f,
cruft/ranlib/getcgn.f, cruft/ranlib/getsd.f, cruft/ranlib/ignbin.f,
cruft/ranlib/ignlgi.f, cruft/ranlib/ignnbn.f, cruft/ranlib/ignpoi.f,
cruft/ranlib/ignuin.f, cruft/ranlib/initgn.f, cruft/ranlib/inrgcm.f,
cruft/ranlib/lennob.f, cruft/ranlib/mltmod.f, cruft/ranlib/module.mk,
cruft/ranlib/phrtsd.f, cruft/ranlib/qrgnin.f, cruft/ranlib/randlib.chs,
cruft/ranlib/randlib.fdoc, cruft/ranlib/ranf.f, cruft/ranlib/setall.f,
cruft/ranlib/setant.f, cruft/ranlib/setgmn.f, cruft/ranlib/setsd.f,
cruft/ranlib/sexpo.f, cruft/ranlib/sgamma.f, cruft/ranlib/snorm.f,
cruft/ranlib/tstbot.for, cruft/ranlib/tstgmn.for, cruft/ranlib/tstmid.for,
cruft/ranlib/wrap.f, cruft/slatec-err/fdump.f, cruft/slatec-err/ixsav.f,
cruft/slatec-err/j4save.f, cruft/slatec-err/module.mk,
cruft/slatec-err/xerclr.f, cruft/slatec-err/xercnt.f,
cruft/slatec-err/xerhlt.f, cruft/slatec-err/xermsg.f,
cruft/slatec-err/xerprn.f, cruft/slatec-err/xerrwd.f,
cruft/slatec-err/xersve.f, cruft/slatec-err/xgetf.f, cruft/slatec-err/xgetua.f,
cruft/slatec-err/xsetf.f, cruft/slatec-err/xsetua.f, cruft/slatec-fn/acosh.f,
cruft/slatec-fn/albeta.f, cruft/slatec-fn/algams.f, cruft/slatec-fn/alngam.f,
cruft/slatec-fn/alnrel.f, cruft/slatec-fn/asinh.f, cruft/slatec-fn/atanh.f,
cruft/slatec-fn/betai.f, cruft/slatec-fn/csevl.f, cruft/slatec-fn/d9gmit.f,
cruft/slatec-fn/d9lgic.f, cruft/slatec-fn/d9lgit.f, cruft/slatec-fn/d9lgmc.f,
cruft/slatec-fn/dacosh.f, cruft/slatec-fn/dasinh.f, cruft/slatec-fn/datanh.f,
cruft/slatec-fn/dbetai.f, cruft/slatec-fn/dcsevl.f, cruft/slatec-fn/derf.f,
cruft/slatec-fn/derfc.in.f, cruft/slatec-fn/dgami.f, cruft/slatec-fn/dgamit.f,
cruft/slatec-fn/dgamlm.f, cruft/slatec-fn/dgamma.f, cruft/slatec-fn/dgamr.f,
cruft/slatec-fn/dlbeta.f, cruft/slatec-fn/dlgams.f, cruft/slatec-fn/dlngam.f,
cruft/slatec-fn/dlnrel.f, cruft/slatec-fn/dpchim.f, cruft/slatec-fn/dpchst.f,
cruft/slatec-fn/erf.f, cruft/slatec-fn/erfc.in.f, cruft/slatec-fn/gami.f,
cruft/slatec-fn/gamit.f, cruft/slatec-fn/gamlim.f, cruft/slatec-fn/gamma.f,
cruft/slatec-fn/gamr.f, cruft/slatec-fn/initds.f, cruft/slatec-fn/inits.f,
cruft/slatec-fn/module.mk, cruft/slatec-fn/pchim.f, cruft/slatec-fn/pchst.f,
cruft/slatec-fn/r9gmit.f, cruft/slatec-fn/r9lgic.f, cruft/slatec-fn/r9lgit.f,
cruft/slatec-fn/r9lgmc.f, cruft/slatec-fn/xacosh.f, cruft/slatec-fn/xasinh.f,
cruft/slatec-fn/xatanh.f, cruft/slatec-fn/xbetai.f, cruft/slatec-fn/xdacosh.f,
cruft/slatec-fn/xdasinh.f, cruft/slatec-fn/xdatanh.f,
cruft/slatec-fn/xdbetai.f, cruft/slatec-fn/xderf.f, cruft/slatec-fn/xderfc.f,
cruft/slatec-fn/xdgami.f, cruft/slatec-fn/xdgamit.f, cruft/slatec-fn/xdgamma.f,
cruft/slatec-fn/xerf.f, cruft/slatec-fn/xerfc.f, cruft/slatec-fn/xgamma.f,
cruft/slatec-fn/xgmainc.f, cruft/slatec-fn/xsgmainc.f:
Moved from top-level libcruft to cruft directory below liboctave.
* numeric/CmplxAEPBAL.cc, numeric/CmplxAEPBAL.h, numeric/CmplxCHOL.cc,
numeric/CmplxCHOL.h, numeric/CmplxGEPBAL.cc, numeric/CmplxGEPBAL.h,
numeric/CmplxHESS.cc, numeric/CmplxHESS.h, numeric/CmplxLU.cc,
numeric/CmplxLU.h, numeric/CmplxQR.cc, numeric/CmplxQR.h, numeric/CmplxQRP.cc,
numeric/CmplxQRP.h, numeric/CmplxSCHUR.cc, numeric/CmplxSCHUR.h,
numeric/CmplxSVD.cc, numeric/CmplxSVD.h, numeric/CollocWt.cc,
numeric/CollocWt.h, numeric/DAE.h, numeric/DAEFunc.h, numeric/DAERT.h,
numeric/DAERTFunc.h, numeric/DASPK-opts.in, numeric/DASPK.cc, numeric/DASPK.h,
numeric/DASRT-opts.in, numeric/DASRT.cc, numeric/DASRT.h,
numeric/DASSL-opts.in, numeric/DASSL.cc, numeric/DASSL.h, numeric/DET.h,
numeric/EIG.cc, numeric/EIG.h, numeric/LSODE-opts.in, numeric/LSODE.cc,
numeric/LSODE.h, numeric/ODE.h, numeric/ODEFunc.h, numeric/ODES.cc,
numeric/ODES.h, numeric/ODESFunc.h, numeric/Quad-opts.in, numeric/Quad.cc,
numeric/Quad.h, numeric/SparseCmplxCHOL.cc, numeric/SparseCmplxCHOL.h,
numeric/SparseCmplxLU.cc, numeric/SparseCmplxLU.h, numeric/SparseCmplxQR.cc,
numeric/SparseCmplxQR.h, numeric/SparseQR.cc, numeric/SparseQR.h,
numeric/SparsedbleCHOL.cc, numeric/SparsedbleCHOL.h, numeric/SparsedbleLU.cc,
numeric/SparsedbleLU.h, numeric/base-aepbal.h, numeric/base-dae.h,
numeric/base-de.h, numeric/base-lu.cc, numeric/base-lu.h, numeric/base-min.h,
numeric/base-qr.cc, numeric/base-qr.h, numeric/bsxfun-decl.h,
numeric/bsxfun-defs.cc, numeric/bsxfun.h, numeric/dbleAEPBAL.cc,
numeric/dbleAEPBAL.h, numeric/dbleCHOL.cc, numeric/dbleCHOL.h,
numeric/dbleGEPBAL.cc, numeric/dbleGEPBAL.h, numeric/dbleHESS.cc,
numeric/dbleHESS.h, numeric/dbleLU.cc, numeric/dbleLU.h, numeric/dbleQR.cc,
numeric/dbleQR.h, numeric/dbleQRP.cc, numeric/dbleQRP.h, numeric/dbleSCHUR.cc,
numeric/dbleSCHUR.h, numeric/dbleSVD.cc, numeric/dbleSVD.h,
numeric/eigs-base.cc, numeric/fCmplxAEPBAL.cc, numeric/fCmplxAEPBAL.h,
numeric/fCmplxCHOL.cc, numeric/fCmplxCHOL.h, numeric/fCmplxGEPBAL.cc,
numeric/fCmplxGEPBAL.h, numeric/fCmplxHESS.cc, numeric/fCmplxHESS.h,
numeric/fCmplxLU.cc, numeric/fCmplxLU.h, numeric/fCmplxQR.cc,
numeric/fCmplxQR.h, numeric/fCmplxQRP.cc, numeric/fCmplxQRP.h,
numeric/fCmplxSCHUR.cc, numeric/fCmplxSCHUR.h, numeric/fCmplxSVD.cc,
numeric/fCmplxSVD.h, numeric/fEIG.cc, numeric/fEIG.h, numeric/floatAEPBAL.cc,
numeric/floatAEPBAL.h, numeric/floatCHOL.cc, numeric/floatCHOL.h,
numeric/floatGEPBAL.cc, numeric/floatGEPBAL.h, numeric/floatHESS.cc,
numeric/floatHESS.h, numeric/floatLU.cc, numeric/floatLU.h, numeric/floatQR.cc,
numeric/floatQR.h, numeric/floatQRP.cc, numeric/floatQRP.h,
numeric/floatSCHUR.cc, numeric/floatSCHUR.h, numeric/floatSVD.cc,
numeric/floatSVD.h, numeric/lo-mappers.cc, numeric/lo-mappers.h,
numeric/lo-specfun.cc, numeric/lo-specfun.h, numeric/module.mk,
numeric/oct-convn.cc, numeric/oct-convn.h, numeric/oct-fftw.cc,
numeric/oct-fftw.h, numeric/oct-norm.cc, numeric/oct-norm.h,
numeric/oct-rand.cc, numeric/oct-rand.h, numeric/oct-spparms.cc,
numeric/oct-spparms.h, numeric/randgamma.c, numeric/randgamma.h,
numeric/randmtzig.c, numeric/randmtzig.h, numeric/randpoisson.c,
numeric/randpoisson.h, numeric/sparse-base-chol.cc, numeric/sparse-base-chol.h,
numeric/sparse-base-lu.cc, numeric/sparse-base-lu.h, numeric/sparse-dmsolve.cc:
Moved from liboctave dir to numeric subdirectory.
* operators/Sparse-diag-op-defs.h, operators/Sparse-op-defs.h,
operators/Sparse-perm-op-defs.h, operators/config-ops.sh, operators/mk-ops.awk,
operators/module.mk, operators/mx-base.h, operators/mx-defs.h,
operators/mx-ext.h, operators/mx-inlines.cc, operators/mx-op-decl.h,
operators/mx-op-defs.h, operators/mx-ops, operators/sparse-mk-ops.awk,
operators/sparse-mx-ops, operators/vx-ops:
Moved from liboctave dir to operators subdirectory.
* system/dir-ops.cc, system/dir-ops.h, system/file-ops.cc, system/file-ops.h,
system/file-stat.cc, system/file-stat.h, system/lo-sysdep.cc,
system/lo-sysdep.h, system/mach-info.cc, system/mach-info.h, system/module.mk,
system/oct-env.cc, system/oct-env.h, system/oct-group.cc, system/oct-group.h,
system/oct-openmp.h, system/oct-passwd.cc, system/oct-passwd.h,
system/oct-syscalls.cc, system/oct-syscalls.h, system/oct-time.cc,
system/oct-time.h, system/oct-uname.cc, system/oct-uname.h, system/pathlen.h,
system/sysdir.h, system/syswait.h, system/tempnam.c, system/tempname.c:
Moved from liboctave dir to system subdirectory.
* util/base-list.h, util/byte-swap.h, util/caseless-str.h, util/cmd-edit.cc,
util/cmd-edit.h, util/cmd-hist.cc, util/cmd-hist.h, util/data-conv.cc,
util/data-conv.h, util/f2c-main.c, util/functor.h, util/glob-match.cc,
util/glob-match.h, util/kpse.cc, util/lo-array-gripes.cc,
util/lo-array-gripes.h, util/lo-cieee.c, util/lo-cutils.c, util/lo-cutils.h,
util/lo-ieee.cc, util/lo-ieee.h, util/lo-macros.h, util/lo-math.h,
util/lo-traits.h, util/lo-utils.cc, util/lo-utils.h, util/module.mk,
util/oct-alloc.cc, util/oct-alloc.h, util/oct-base64.cc, util/oct-base64.h,
util/oct-binmap.h, util/oct-cmplx.h, util/oct-glob.cc, util/oct-glob.h,
util/oct-inttypes.cc, util/oct-inttypes.h, util/oct-locbuf.cc,
util/oct-locbuf.h, util/oct-md5.cc, util/oct-md5.h, util/oct-mem.h,
util/oct-mutex.cc, util/oct-mutex.h, util/oct-refcount.h, util/oct-rl-edit.c,
util/oct-rl-edit.h, util/oct-rl-hist.c, util/oct-rl-hist.h, util/oct-shlib.cc,
util/oct-shlib.h, util/oct-sort.cc, util/oct-sort.h, util/oct-sparse.h,
util/pathsearch.cc, util/pathsearch.h, util/regexp.cc, util/regexp.h,
util/singleton-cleanup.cc, util/singleton-cleanup.h, util/sparse-sort.cc,
util/sparse-sort.h, util/sparse-util.cc, util/sparse-util.h, util/statdefs.h,
util/str-vec.cc, util/str-vec.h, util/sun-utils.h:
Moved from liboctave dir to util subdirectory.
* Makefile.am: Eliminate reference to top-level liboctave directory.
* autogen.sh: cd to new liboctave/operators directory to run config-ops.sh.
* build-aux/common.mk: Eliminate LIBCRUFT references.
* configure.ac: Eliminate libcruft top-level references. Switch test
programs to find files in liboctave/cruft subdirectory.
* OctaveFAQ.texi, install.txi, mkoctfile.1: Eliminate references to libcruft in
docs.
* libgui/src/Makefile.am, libinterp/Makefile.am, src/Makefile.am: Update
include file locations. Stop linking against libcruft.
* libinterp/corefcn/module.mk: Update location of OPT_INC files which are
now in numeric/ subdirectory.
* libinterp/dldfcn/config-module.awk: Stop linking against libcruft.
* libinterp/interpfcn/toplev.cc: Remove reference to LIBCRUFT.
* libinterp/link-deps.mk, liboctave/link-deps.mk:
Add GNULIB_LINK_DEPS to link dependencies.
* libinterp/oct-conf.in.h: Remove reference to OCTAVE_CONF_LIBCRUFT.
* liboctave/Makefile.am: Overhaul to use convenience libraries in
subdirectories.
* scripts/miscellaneous/mkoctfile.m: Eliminate reference to LIBCRUFT.
* src/mkoctfile.in.cc, src/mkoctfile.in.sh: Stop linking againt libcruft.
Eliminate references to LIBCRUFT.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 31 Aug 2012 20:00:20 -0700 |
parents | liboctave/file-ops.cc@460a3c6d8bf1 |
children | c898dbe14e1d |
comparison
equal
deleted
inserted
replaced
15270:6615a46d90ec | 15271:648dabbb4c6b |
---|---|
1 /* | |
2 | |
3 Copyright (C) 1996-2012 John W. Eaton | |
4 | |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 3 of the License, or (at your | |
10 option) any later version. | |
11 | |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with Octave; see the file COPYING. If not, see | |
19 <http://www.gnu.org/licenses/>. | |
20 | |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include <cerrno> | |
28 #include <cstdio> | |
29 #include <cstdlib> | |
30 #include <cstring> | |
31 | |
32 #include <iostream> | |
33 #include <vector> | |
34 | |
35 #include <sys/stat.h> | |
36 #include <sys/types.h> | |
37 #include <unistd.h> | |
38 | |
39 #include "pathmax.h" | |
40 | |
41 #include "dir-ops.h" | |
42 #include "file-ops.h" | |
43 #include "file-stat.h" | |
44 #include "oct-env.h" | |
45 #include "oct-locbuf.h" | |
46 #include "oct-passwd.h" | |
47 #include "pathlen.h" | |
48 #include "quit.h" | |
49 #include "singleton-cleanup.h" | |
50 #include "str-vec.h" | |
51 | |
52 file_ops *file_ops::instance = 0; | |
53 | |
54 bool | |
55 file_ops::instance_ok (void) | |
56 { | |
57 bool retval = true; | |
58 | |
59 if (! instance) | |
60 { | |
61 #if (defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) && ! defined (OCTAVE_HAVE_POSIX_FILESYSTEM)) | |
62 char system_dir_sep_char = '\\'; | |
63 std::string system_dir_sep_str = "\\"; | |
64 #else | |
65 char system_dir_sep_char = '/'; | |
66 std::string system_dir_sep_str = "/"; | |
67 #endif | |
68 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) | |
69 std::string system_dir_sep_chars = "/\\"; | |
70 #else | |
71 std::string system_dir_sep_chars = system_dir_sep_str; | |
72 #endif | |
73 | |
74 instance = new file_ops (system_dir_sep_char, system_dir_sep_str, | |
75 system_dir_sep_chars); | |
76 | |
77 if (instance) | |
78 singleton_cleanup_list::add (cleanup_instance); | |
79 } | |
80 | |
81 if (! instance) | |
82 { | |
83 (*current_liboctave_error_handler) | |
84 ("unable to create file_ops object!"); | |
85 | |
86 retval = false; | |
87 } | |
88 | |
89 return retval; | |
90 } | |
91 | |
92 // The following tilde-expansion code was stolen and adapted from | |
93 // readline. | |
94 | |
95 // The default value of tilde_additional_prefixes. This is set to | |
96 // whitespace preceding a tilde so that simple programs which do not | |
97 // perform any word separation get desired behaviour. | |
98 static const char *default_prefixes[] = { " ~", "\t~", ":~", 0 }; | |
99 | |
100 // The default value of tilde_additional_suffixes. This is set to | |
101 // whitespace or newline so that simple programs which do not perform | |
102 // any word separation get desired behaviour. | |
103 static const char *default_suffixes[] = { " ", "\n", ":", 0 }; | |
104 | |
105 // If non-null, this contains the address of a function that the | |
106 // application wants called before trying the standard tilde | |
107 // expansions. The function is called with the text sans tilde, and | |
108 // returns a malloc()'ed string which is the expansion, or a NULL | |
109 // pointer if the expansion fails. | |
110 file_ops::tilde_expansion_hook file_ops::tilde_expansion_preexpansion_hook = 0; | |
111 | |
112 // If non-null, this contains the address of a function to call if the | |
113 // standard meaning for expanding a tilde fails. The function is | |
114 // called with the text (sans tilde, as in "foo"), and returns a | |
115 // malloc()'ed string which is the expansion, or a NULL pointer if | |
116 // there is no expansion. | |
117 file_ops::tilde_expansion_hook file_ops::tilde_expansion_failure_hook = 0; | |
118 | |
119 // When non-null, this is a NULL terminated array of strings which are | |
120 // duplicates for a tilde prefix. Bash uses this to expand `=~' and | |
121 // `:~'. | |
122 string_vector file_ops::tilde_additional_prefixes = default_prefixes; | |
123 | |
124 // When non-null, this is a NULL terminated array of strings which | |
125 // match the end of a username, instead of just "/". Bash sets this | |
126 // to `:' and `=~'. | |
127 string_vector file_ops::tilde_additional_suffixes = default_suffixes; | |
128 | |
129 // Find the start of a tilde expansion in S, and return the index | |
130 // of the tilde which starts the expansion. Place the length of the | |
131 // text which identified this tilde starter in LEN, excluding the | |
132 // tilde itself. | |
133 | |
134 static size_t | |
135 tilde_find_prefix (const std::string& s, size_t& len) | |
136 { | |
137 len = 0; | |
138 | |
139 size_t s_len = s.length (); | |
140 | |
141 if (s_len == 0 || s[0] == '~') | |
142 return 0; | |
143 | |
144 string_vector prefixes = file_ops::tilde_additional_prefixes; | |
145 | |
146 if (! prefixes.empty ()) | |
147 { | |
148 for (size_t i = 0; i < s_len; i++) | |
149 { | |
150 for (int j = 0; j < prefixes.length (); j++) | |
151 { | |
152 size_t pfx_len = prefixes[j].length (); | |
153 | |
154 if (prefixes[j].compare (s.substr (i, pfx_len)) == 0) | |
155 { | |
156 len = pfx_len - 1; | |
157 return i + len; | |
158 } | |
159 } | |
160 } | |
161 } | |
162 | |
163 return s_len; | |
164 } | |
165 | |
166 // Find the end of a tilde expansion in S, and return the index | |
167 // of the character which ends the tilde definition. | |
168 | |
169 static size_t | |
170 tilde_find_suffix (const std::string& s) | |
171 { | |
172 size_t s_len = s.length (); | |
173 | |
174 string_vector suffixes = file_ops::tilde_additional_suffixes; | |
175 | |
176 size_t i = 0; | |
177 | |
178 for ( ; i < s_len; i++) | |
179 { | |
180 if (file_ops::is_dir_sep (s[i])) | |
181 break; | |
182 | |
183 if (! suffixes.empty ()) | |
184 { | |
185 for (int j = 0; j < suffixes.length (); j++) | |
186 { | |
187 size_t sfx_len = suffixes[j].length (); | |
188 | |
189 if (suffixes[j].compare (s.substr (i, sfx_len)) == 0) | |
190 return i; | |
191 } | |
192 } | |
193 } | |
194 | |
195 return i; | |
196 } | |
197 | |
198 // Take FNAME and return the tilde prefix we want expanded. | |
199 | |
200 static std::string | |
201 isolate_tilde_prefix (const std::string& fname) | |
202 { | |
203 size_t f_len = fname.length (); | |
204 | |
205 size_t len = 1; | |
206 | |
207 while (len < f_len && ! file_ops::is_dir_sep (fname[len])) | |
208 len++; | |
209 | |
210 return fname.substr (1, len); | |
211 } | |
212 | |
213 // Do the work of tilde expansion on FILENAME. FILENAME starts with a | |
214 // tilde. | |
215 | |
216 static std::string | |
217 tilde_expand_word (const std::string& filename) | |
218 { | |
219 size_t f_len = filename.length (); | |
220 | |
221 if (f_len == 0 || filename[0] != '~') | |
222 return filename; | |
223 | |
224 // A leading `~/' or a bare `~' is *always* translated to the value | |
225 // of $HOME or the home directory of the current user, regardless of | |
226 // any preexpansion hook. | |
227 | |
228 if (f_len == 1 || file_ops::is_dir_sep (filename[1])) | |
229 return octave_env::get_home_directory () + filename.substr (1); | |
230 | |
231 std::string username = isolate_tilde_prefix (filename); | |
232 | |
233 size_t user_len = username.length (); | |
234 | |
235 std::string dirname; | |
236 | |
237 if (file_ops::tilde_expansion_preexpansion_hook) | |
238 { | |
239 std::string expansion | |
240 = file_ops::tilde_expansion_preexpansion_hook (username); | |
241 | |
242 if (! expansion.empty ()) | |
243 return expansion + filename.substr (user_len+1); | |
244 } | |
245 | |
246 // No preexpansion hook, or the preexpansion hook failed. Look in the | |
247 // password database. | |
248 | |
249 octave_passwd pw = octave_passwd::getpwnam (username); | |
250 | |
251 if (! pw) | |
252 { | |
253 // If the calling program has a special syntax for expanding tildes, | |
254 // and we couldn't find a standard expansion, then let them try. | |
255 | |
256 if (file_ops::tilde_expansion_failure_hook) | |
257 { | |
258 std::string expansion | |
259 = file_ops::tilde_expansion_failure_hook (username); | |
260 | |
261 if (! expansion.empty ()) | |
262 dirname = expansion + filename.substr (user_len+1); | |
263 } | |
264 | |
265 // If we don't have a failure hook, or if the failure hook did not | |
266 // expand the tilde, return a copy of what we were passed. | |
267 | |
268 if (dirname.length () == 0) | |
269 dirname = filename; | |
270 } | |
271 else | |
272 dirname = pw.dir () + filename.substr (user_len+1); | |
273 | |
274 return dirname; | |
275 } | |
276 | |
277 // If NAME has a leading ~ or ~user, Unix-style, expand it to the | |
278 // user's home directory. If no ~, or no <pwd.h>, just return NAME. | |
279 | |
280 std::string | |
281 file_ops::tilde_expand (const std::string& name) | |
282 { | |
283 if (name.find ('~') == std::string::npos) | |
284 return name; | |
285 else | |
286 { | |
287 std::string result; | |
288 | |
289 size_t name_len = name.length (); | |
290 | |
291 // Scan through S expanding tildes as we come to them. | |
292 | |
293 size_t pos = 0; | |
294 | |
295 while (1) | |
296 { | |
297 if (pos > name_len) | |
298 break; | |
299 | |
300 size_t len; | |
301 | |
302 // Make START point to the tilde which starts the expansion. | |
303 | |
304 size_t start = tilde_find_prefix (name.substr (pos), len); | |
305 | |
306 result.append (name.substr (pos, start)); | |
307 | |
308 // Advance STRING to the starting tilde. | |
309 | |
310 pos += start; | |
311 | |
312 // Make FINI be the index of one after the last character of the | |
313 // username. | |
314 | |
315 size_t fini = tilde_find_suffix (name.substr (pos)); | |
316 | |
317 // If both START and FINI are zero, we are all done. | |
318 | |
319 if (! (start || fini)) | |
320 break; | |
321 | |
322 // Expand the entire tilde word, and copy it into RESULT. | |
323 | |
324 std::string tilde_word = name.substr (pos, fini); | |
325 | |
326 pos += fini; | |
327 | |
328 std::string expansion = tilde_expand_word (tilde_word); | |
329 | |
330 result.append (expansion); | |
331 } | |
332 | |
333 return result; | |
334 } | |
335 } | |
336 | |
337 // A vector version of the above. | |
338 | |
339 string_vector | |
340 file_ops::tilde_expand (const string_vector& names) | |
341 { | |
342 string_vector retval; | |
343 | |
344 int n = names.length (); | |
345 | |
346 retval.resize (n); | |
347 | |
348 for (int i = 0; i < n; i++) | |
349 retval[i] = tilde_expand (names[i]); | |
350 | |
351 return retval; | |
352 } | |
353 | |
354 std::string | |
355 file_ops::concat (const std::string& dir, const std::string& file) | |
356 { | |
357 return dir.empty () | |
358 ? file | |
359 : (is_dir_sep (dir[dir.length ()-1]) | |
360 ? dir + file | |
361 : dir + dir_sep_char () + file); | |
362 } | |
363 | |
364 | |
365 int | |
366 octave_mkdir (const std::string& nm, mode_t md) | |
367 { | |
368 std::string msg; | |
369 return octave_mkdir (nm, md, msg); | |
370 } | |
371 | |
372 int | |
373 octave_mkdir (const std::string& name, mode_t mode, std::string& msg) | |
374 { | |
375 msg = std::string (); | |
376 | |
377 int status = -1; | |
378 | |
379 status = gnulib::mkdir (name.c_str (), mode); | |
380 | |
381 if (status < 0) | |
382 msg = gnulib::strerror (errno); | |
383 | |
384 return status; | |
385 } | |
386 | |
387 int | |
388 octave_mkfifo (const std::string& nm, mode_t md) | |
389 { | |
390 std::string msg; | |
391 return octave_mkfifo (nm, md, msg); | |
392 } | |
393 | |
394 int | |
395 octave_mkfifo (const std::string& name, mode_t mode, std::string& msg) | |
396 { | |
397 msg = std::string (); | |
398 | |
399 int status = -1; | |
400 | |
401 // With gnulib we will always have mkfifo, but some systems like MinGW | |
402 // don't have working mkfifo functions. On those systems, mkfifo will | |
403 // always return -1 and set errno. | |
404 | |
405 status = gnulib::mkfifo (name.c_str (), mode); | |
406 | |
407 if (status < 0) | |
408 msg = gnulib::strerror (errno); | |
409 | |
410 return status; | |
411 } | |
412 | |
413 int | |
414 octave_link (const std::string& old_name, const std::string& new_name) | |
415 { | |
416 std::string msg; | |
417 return octave_link (old_name, new_name, msg); | |
418 } | |
419 | |
420 int | |
421 octave_link (const std::string& old_name, | |
422 const std::string& new_name, std::string& msg) | |
423 { | |
424 msg = std::string (); | |
425 | |
426 int status = -1; | |
427 | |
428 status = gnulib::link (old_name.c_str (), new_name.c_str ()); | |
429 | |
430 if (status < 0) | |
431 msg = gnulib::strerror (errno); | |
432 | |
433 return status; | |
434 } | |
435 | |
436 int | |
437 octave_symlink (const std::string& old_name, const std::string& new_name) | |
438 { | |
439 std::string msg; | |
440 return octave_symlink (old_name, new_name, msg); | |
441 } | |
442 | |
443 int | |
444 octave_symlink (const std::string& old_name, | |
445 const std::string& new_name, std::string& msg) | |
446 { | |
447 msg = std::string (); | |
448 | |
449 int status = -1; | |
450 | |
451 status = gnulib::symlink (old_name.c_str (), new_name.c_str ()); | |
452 | |
453 if (status < 0) | |
454 msg = gnulib::strerror (errno); | |
455 | |
456 return status; | |
457 } | |
458 | |
459 int | |
460 octave_readlink (const std::string& path, std::string& result) | |
461 { | |
462 std::string msg; | |
463 return octave_readlink (path, result, msg); | |
464 } | |
465 | |
466 int | |
467 octave_readlink (const std::string& path, std::string& result, | |
468 std::string& msg) | |
469 { | |
470 int status = -1; | |
471 | |
472 msg = std::string (); | |
473 | |
474 char buf[MAXPATHLEN+1]; | |
475 | |
476 status = gnulib::readlink (path.c_str (), buf, MAXPATHLEN); | |
477 | |
478 if (status < 0) | |
479 msg = gnulib::strerror (errno); | |
480 else | |
481 { | |
482 buf[status] = '\0'; | |
483 result = std::string (buf); | |
484 status = 0; | |
485 } | |
486 | |
487 return status; | |
488 } | |
489 | |
490 int | |
491 octave_rename (const std::string& from, const std::string& to) | |
492 { | |
493 std::string msg; | |
494 return octave_rename (from, to, msg); | |
495 } | |
496 | |
497 int | |
498 octave_rename (const std::string& from, const std::string& to, | |
499 std::string& msg) | |
500 { | |
501 int status = -1; | |
502 | |
503 msg = std::string (); | |
504 | |
505 status = gnulib::rename (from.c_str (), to.c_str ()); | |
506 | |
507 if (status < 0) | |
508 msg = gnulib::strerror (errno); | |
509 | |
510 return status; | |
511 } | |
512 | |
513 int | |
514 octave_rmdir (const std::string& name) | |
515 { | |
516 std::string msg; | |
517 return octave_rmdir (name, msg); | |
518 } | |
519 | |
520 int | |
521 octave_rmdir (const std::string& name, std::string& msg) | |
522 { | |
523 msg = std::string (); | |
524 | |
525 int status = -1; | |
526 | |
527 status = gnulib::rmdir (name.c_str ()); | |
528 | |
529 if (status < 0) | |
530 msg = gnulib::strerror (errno); | |
531 | |
532 return status; | |
533 } | |
534 | |
535 // And a version that works recursively. | |
536 | |
537 int | |
538 octave_recursive_rmdir (const std::string& name) | |
539 { | |
540 std::string msg; | |
541 return octave_recursive_rmdir (name, msg); | |
542 } | |
543 | |
544 int | |
545 octave_recursive_rmdir (const std::string& name, std::string& msg) | |
546 { | |
547 msg = std::string (); | |
548 | |
549 int status = 0; | |
550 | |
551 dir_entry dir (name); | |
552 | |
553 if (dir) | |
554 { | |
555 string_vector dirlist = dir.read (); | |
556 | |
557 for (octave_idx_type i = 0; i < dirlist.length (); i++) | |
558 { | |
559 octave_quit (); | |
560 | |
561 std::string nm = dirlist[i]; | |
562 | |
563 // Skip current directory and parent. | |
564 if (nm == "." || nm == "..") | |
565 continue; | |
566 | |
567 std::string fullnm = name + file_ops::dir_sep_str () + nm; | |
568 | |
569 // Get info about the file. Don't follow links. | |
570 file_stat fs (fullnm, false); | |
571 | |
572 if (fs) | |
573 { | |
574 if (fs.is_dir ()) | |
575 { | |
576 status = octave_recursive_rmdir (fullnm, msg); | |
577 | |
578 if (status < 0) | |
579 break; | |
580 } | |
581 else | |
582 { | |
583 status = octave_unlink (fullnm, msg); | |
584 | |
585 if (status < 0) | |
586 break; | |
587 } | |
588 } | |
589 else | |
590 { | |
591 msg = fs.error (); | |
592 break; | |
593 } | |
594 } | |
595 | |
596 if (status >= 0) | |
597 { | |
598 dir.close (); | |
599 status = octave_rmdir (name, msg); | |
600 } | |
601 } | |
602 else | |
603 { | |
604 status = -1; | |
605 | |
606 msg = dir.error (); | |
607 } | |
608 | |
609 return status; | |
610 } | |
611 | |
612 int | |
613 octave_umask (mode_t mode) | |
614 { | |
615 #if defined (HAVE_UMASK) | |
616 return umask (mode); | |
617 #else | |
618 return 0; | |
619 #endif | |
620 } | |
621 | |
622 int | |
623 octave_unlink (const std::string& name) | |
624 { | |
625 std::string msg; | |
626 return octave_unlink (name, msg); | |
627 } | |
628 | |
629 int | |
630 octave_unlink (const std::string& name, std::string& msg) | |
631 { | |
632 msg = std::string (); | |
633 | |
634 int status = -1; | |
635 | |
636 status = gnulib::unlink (name.c_str ()); | |
637 | |
638 if (status < 0) | |
639 msg = gnulib::strerror (errno); | |
640 | |
641 return status; | |
642 } | |
643 | |
644 std::string | |
645 octave_tempnam (const std::string& dir, const std::string& pfx) | |
646 { | |
647 std::string msg; | |
648 return octave_tempnam (dir, pfx, msg); | |
649 } | |
650 | |
651 std::string | |
652 octave_tempnam (const std::string& dir, const std::string& pfx, | |
653 std::string& msg) | |
654 { | |
655 msg = std::string (); | |
656 | |
657 std::string retval; | |
658 | |
659 const char *pdir = dir.empty () ? 0 : dir.c_str (); | |
660 | |
661 const char *ppfx = pfx.empty () ? 0 : pfx.c_str (); | |
662 | |
663 char *tmp = tempnam (pdir, ppfx); | |
664 | |
665 if (tmp) | |
666 { | |
667 retval = tmp; | |
668 | |
669 free (tmp); | |
670 } | |
671 else | |
672 msg = gnulib::strerror (errno); | |
673 | |
674 return retval; | |
675 } | |
676 | |
677 std::string | |
678 octave_canonicalize_file_name (const std::string& name) | |
679 { | |
680 std::string msg; | |
681 return octave_canonicalize_file_name (name, msg); | |
682 } | |
683 | |
684 std::string | |
685 octave_canonicalize_file_name (const std::string& name, std::string& msg) | |
686 { | |
687 msg = std::string (); | |
688 | |
689 std::string retval; | |
690 | |
691 #if defined (HAVE_CANONICALIZE_FILE_NAME) | |
692 | |
693 char *tmp = gnulib::canonicalize_file_name (name.c_str ()); | |
694 | |
695 if (tmp) | |
696 { | |
697 retval = tmp; | |
698 free (tmp); | |
699 } | |
700 | |
701 #elif defined (HAVE_RESOLVEPATH) | |
702 | |
703 #if !defined (errno) | |
704 extern int errno; | |
705 #endif | |
706 | |
707 #if !defined (__set_errno) | |
708 # define __set_errno(Val) errno = (Val) | |
709 #endif | |
710 | |
711 if (name.empty ()) | |
712 { | |
713 __set_errno (ENOENT); | |
714 return retval; | |
715 } | |
716 | |
717 // All known hosts with resolvepath (e.g. Solaris 7) don't turn | |
718 // relative names into absolute ones, so prepend the working | |
719 // directory if the path is not absolute. | |
720 | |
721 std::string absolute_name = octave_env::make_absolute (name); | |
722 | |
723 size_t resolved_size = absolute_name.length (); | |
724 | |
725 while (true) | |
726 { | |
727 resolved_size = 2 * resolved_size + 1; | |
728 | |
729 OCTAVE_LOCAL_BUFFER (char, resolved, resolved_size); | |
730 | |
731 int resolved_len | |
732 = resolvepath (absolute_name.c_str (), resolved, resolved_size); | |
733 | |
734 if (resolved_len < 0) | |
735 break; | |
736 | |
737 if (resolved_len < resolved_size) | |
738 { | |
739 retval = resolved; | |
740 break; | |
741 } | |
742 } | |
743 | |
744 #elif defined (__WIN32__) | |
745 | |
746 int n = 1024; | |
747 | |
748 std::string win_path (n, '\0'); | |
749 | |
750 while (true) | |
751 { | |
752 int status = GetFullPathName (name.c_str (), n, &win_path[0], 0); | |
753 | |
754 if (status == 0) | |
755 break; | |
756 else if (status < n) | |
757 { | |
758 win_path.resize (status); | |
759 retval = win_path; | |
760 break; | |
761 } | |
762 else | |
763 { | |
764 n *= 2; | |
765 win_path.resize (n); | |
766 } | |
767 } | |
768 | |
769 #elif defined (HAVE_REALPATH) | |
770 | |
771 #if !defined (__set_errno) | |
772 # define __set_errno(Val) errno = (Val) | |
773 #endif | |
774 | |
775 if (name.empty ()) | |
776 { | |
777 __set_errno (ENOENT); | |
778 return retval; | |
779 } | |
780 | |
781 OCTAVE_LOCAL_BUFFER (char, buf, PATH_MAX); | |
782 | |
783 if (::realpath (name.c_str (), buf)) | |
784 retval = buf; | |
785 | |
786 #else | |
787 | |
788 // FIXME -- provide replacement here... | |
789 retval = name; | |
790 | |
791 #endif | |
792 | |
793 if (retval.empty ()) | |
794 msg = gnulib::strerror (errno); | |
795 | |
796 return retval; | |
797 } | |
798 |