Mercurial > octave
annotate liboctave/system/lo-sysdep.cc @ 23795:980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
* Backend.cc, BaseControl.h, ButtonGroup.cc, CheckBoxControl.cc,
Container.cc, ContextMenu.cc, ContextMenu.h, EditControl.cc, Figure.cc,
FigureWindow.cc, ListBoxControl.cc, Menu.cc, Menu.h, MouseModeActionGroup.cc,
Object.cc, ObjectProxy.cc, Panel.cc, PopupMenuControl.cc, PushButtonControl.cc,
PushTool.cc, RadioButtonControl.cc, SliderControl.cc, TextControl.cc,
ToggleButtonControl.cc, ToggleTool.cc, ToolBar.cc, ToolBar.h, ToolBarButton.cc,
ToolBarButton.h, QTerminal.h, BlockArray.cpp, Emulation.cpp, Filter.cpp,
Filter.h, History.cpp, KeyboardTranslator.cpp, QUnixTerminalImpl.h, Screen.cpp,
ScreenWindow.cpp, ScreenWindow.h, SelfListener.h, TerminalCharacterDecoder.cpp,
TerminalModel.cpp, TerminalView.cpp, TerminalView.h, kpty.cpp, dialog.cc,
dialog.h, files-dock-widget.cc, find-files-model.h, file-editor-tab.cc,
file-editor.cc, main-window.cc, octave-dock-widget.cc, octave-gui.cc,
parser.cc, resource-manager.cc, resource-manager.h, shortcut-manager.cc,
shortcut-manager.h, workspace-model.cc, workspace-view.cc, __magick_read__.cc,
c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h,
daspk.cc, dasrt.cc, dassl.cc, det.cc, display.h, error.cc, ft-text-renderer.cc,
gl-render.cc, gl2ps-print.cc, graphics.in.h, help.cc, input.cc, interpreter.cc,
load-path.cc, load-save.cc, ls-hdf5.cc, ls-hdf5.h, ls-mat5.cc, lsode.cc,
mex.cc, mxarray.in.h, oct-errno.h, oct-hist.cc, oct-iostrm.h, oct-procbuf.cc,
oct-procbuf.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.h,
oct-tex-parser.in.yy, octave-link.h, pager.cc, pager.h, pr-output.cc,
procstream.h, qz.cc, sighandlers.cc, svd.cc, symtab.cc, symtab.h,
text-renderer.cc, txt-eng.h, utils.cc, variables.cc, zfstream.cc, zfstream.h,
__glpk__.cc, __init_fltk__.cc, __ode15__.cc, audiodevinfo.cc, ccolamd.cc,
colamd.cc, dmperm.cc, gzip.cc, symbfact.cc, ov-base-int.cc, ov-base-int.h,
ov-base-mat.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-sparse.cc,
ov-bool.cc, ov-builtin.h, ov-cell.cc, ov-class.cc, ov-complex.cc, ov-cx-mat.cc,
ov-cx-sparse.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-fcn.cc, ov-fcn.h,
ov-float.cc, ov-flt-complex.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-java.cc,
ov-java.h, ov-mex-fcn.cc, ov-oncleanup.cc, ov-range.cc, ov-range.h,
ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc, ov-typeinfo.cc,
ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, octave.cc, bp-table.cc,
bp-table.h, jit-ir.h, jit-typeinfo.cc, lex.h, profiler.cc, pt-arg-list.cc,
pt-array-list.cc, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h,
pt-cell.cc, pt-classdef.cc, pt-classdef.h, pt-colon.cc, pt-colon.h, pt-decl.cc,
pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.h, pt-fcn-handle.cc,
pt-fcn-handle.h, pt-idx.cc, pt-jit.cc, pt-loop.h, pt-mat.cc, pt-select.h,
pt-stmt.h, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt.cc, Array-C.cc, Array-d.cc,
Array-f.cc, Array-fC.cc, Array-util.cc, Array.cc, Array.h, CMatrix.cc,
CSparse.cc, DiagArray2.h, MArray.h, MDiagArray2.h, MatrixType.cc, Sparse.cc,
Sparse.h, dMatrix.cc, dSparse.cc, fMatrix.cc, idx-vector.cc, idx-vector.h,
DAEFunc.h, DAERTFunc.h, ODEFunc.h, ODESFunc.h, eigs-base.cc, oct-fftw.cc,
oct-fftw.h, oct-rand.h, oct-spparms.h, schur.cc, sparse-chol.cc,
sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, child-list.h, dir-ops.cc,
dir-ops.h, file-ops.cc, lo-sysdep.cc, oct-env.h, oct-time.cc, cmd-edit.cc,
cmd-edit.h, cmd-hist.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, oct-shlib.cc,
oct-shlib.h, oct-sort.cc, oct-sort.h, quit.cc, singleton-cleanup.h, str-vec.cc:
Use C++11 nullptr rather than 0 in code (bug #51565).
author | Rik <rik@octave.org> |
---|---|
date | Tue, 25 Jul 2017 14:54:10 -0700 |
parents | 08036a7f3660 |
children | 8057d3f0673d |
rev | line source |
---|---|
2926 | 1 /* |
2 | |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
3 Copyright (C) 1996-2017 John W. Eaton |
2926 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
8 under the terms of the GNU General Public License as published by |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
9 the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
10 (at your option) any later version. |
2926 | 11 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
13 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22402
diff
changeset
|
15 GNU General Public License for more details. |
2926 | 16 |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2926 | 20 |
21 */ | |
22 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21642
diff
changeset
|
23 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21213
diff
changeset
|
24 # include "config.h" |
2926 | 25 #endif |
26 | |
27 #include <string> | |
7695
eacf87a24f55
lo-sysdep.cc: include windows.h if windows and not cygwin
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
28 |
5872 | 29 #include "file-ops.h" |
3069 | 30 #include "lo-error.h" |
21910
4d723ba06b4a
provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents:
21828
diff
changeset
|
31 #include "lo-sysdep.h" |
4d723ba06b4a
provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents:
21828
diff
changeset
|
32 #include "unistd-wrappers.h" |
2926 | 33 |
21738
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
34 namespace octave |
2926 | 35 { |
21738
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
36 namespace sys |
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
37 { |
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
38 std::string |
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
39 getcwd (void) |
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
40 { |
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
41 std::string retval; |
3069 | 42 |
21910
4d723ba06b4a
provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents:
21828
diff
changeset
|
43 // Using octave_getcwd_wrapper ensures that we have a getcwd that |
21738
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
44 // will allocate a buffer as large as necessary if buf and size are |
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
45 // both 0. |
3069 | 46 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23696
diff
changeset
|
47 char *tmp = octave_getcwd_wrapper (nullptr, 0); |
2926 | 48 |
21738
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
49 if (! tmp) |
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
50 (*current_liboctave_error_handler) ("unable to find current directory"); |
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
51 |
10250 | 52 retval = tmp; |
53 free (tmp); | |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
19864
diff
changeset
|
54 |
21738
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
55 return retval; |
10250 | 56 } |
2926 | 57 |
21738
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
58 int |
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
59 chdir (const std::string& path_arg) |
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
60 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
61 std::string path = sys::file_ops::tilde_expand (path_arg); |
5872 | 62 |
21979
d04da18a407a
use OCTAVE_USE_WINDOWS_API more consistently
John W. Eaton <jwe@octave.org>
parents:
21949
diff
changeset
|
63 #if defined (OCTAVE_USE_WINDOWS_API) |
21738
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
64 if (path.length () == 2 && path[1] == ':') |
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
65 path += "\\"; |
6244 | 66 #endif |
67 | |
21910
4d723ba06b4a
provide wrappers for some unistd.h functions
John W. Eaton <jwe@octave.org>
parents:
21828
diff
changeset
|
68 return octave_chdir_wrapper (path.c_str ()); |
21738
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
69 } |
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
70 } |
a99c2407f930
use namespace for lo-sysdep.h functions
John W. Eaton <jwe@octave.org>
parents:
21733
diff
changeset
|
71 } |