comparison src/file-io.cc @ 4267:7cd865a8c815

[project @ 2003-01-03 15:27:05 by jwe]
author jwe
date Fri, 03 Jan 2003 15:27:06 +0000
parents e556870ce8f0
children 1cae4472c624
comparison
equal deleted inserted replaced
4266:1086ac09a411 4267:7cd865a8c815
1475 return retval; 1475 return retval;
1476 } 1476 }
1477 1477
1478 DEFUN (tmpnam, args, , 1478 DEFUN (tmpnam, args, ,
1479 "-*- texinfo -*-\n\ 1479 "-*- texinfo -*-\n\
1480 @deftypefn {Built-in Function} {} tmpnam ()\n\ 1480 @deftypefn {Built-in Function} {} tmpnam (@var{dir}, @var{prefix})\n\
1481 Return a unique temporary file name as a string.\n\ 1481 Return a unique temporary file name as a string.\n\
1482 \n\ 1482 \n\
1483 Since the named file is not opened, by @code{tmpnam}, it\n\ 1483 If @var{prefix} is omitted, a value of @code{\"oct-\"} is used.\n\
1484 is possible (though relatively unlikely) that it will not be available\n\ 1484 If @var{dir} is also omitted, the default directory for temporary files\n\
1485 by the time your program attempts to open it.\n\ 1485 is used. If @var{dir} is provided, it must exist, otherwise the default\n\
1486 directory for temporary files is used. Since the named file is not\n\
1487 opened, by @code{tmpnam}, it is possible (though relatively unlikely)\n\
1488 that it will not be available by the time your program attempts to open it.\n\
1486 @end deftypefn") 1489 @end deftypefn")
1487 { 1490 {
1488 octave_value retval; 1491 octave_value retval;
1489 1492
1490 int len = args.length (); 1493 int len = args.length ();
1491 1494
1492 if (len < 3) 1495 if (len < 3)
1493 { 1496 {
1494 std::string dir = len > 0 ? args(0).string_value () : std::string (); 1497 std::string dir = len > 0 ? args(0).string_value () : std::string ();
1495 std::string pfx = len > 1 ? args(1).string_value () : std::string ("oct-"); 1498
1496 1499 if (! error_state)
1497 if (! error_state) 1500 {
1498 retval = file_ops::tempnam (dir, pfx); 1501 std::string pfx
1502 = len > 1 ? args(1).string_value () : std::string ("oct-");
1503
1504 if (! error_state)
1505 retval = file_ops::tempnam (dir, pfx);
1506 else
1507 ::error ("expecting second argument to be a string");
1508 }
1509 else
1510 ::error ("expecting first argument to be a string");
1499 } 1511 }
1500 else 1512 else
1501 print_usage ("tmpnam"); 1513 print_usage ("tmpnam");
1502 1514
1503 return retval; 1515 return retval;
1582 } 1594 }
1583 1595
1584 void 1596 void
1585 symbols_of_file_io (void) 1597 symbols_of_file_io (void)
1586 { 1598 {
1599 #if ! defined (P_tmpdir)
1600 #define P_tmpdir "/tmp"
1601 #endif
1602
1603 DEFCONSTX ("P_tmpdir", SBV_P_tmpdir, P_tmpdir,
1604 "-*- texinfo -*-\n\
1605 @defvr {Built-in Variable} P_tmpdir\n\
1606 The default name of the directory for temporary files on this system.\n\
1607 of this variable is system dependent.\n\
1608 @end defvr");
1609
1587 // NOTE: the values of SEEK_SET, SEEK_CUR, and SEEK_END have to be 1610 // NOTE: the values of SEEK_SET, SEEK_CUR, and SEEK_END have to be
1588 // this way for Matlab compatibility. 1611 // this way for Matlab compatibility.
1589 1612
1590 DEFCONSTX ("SEEK_SET", SBV_SEEK_SET, -1, 1613 DEFCONSTX ("SEEK_SET", SBV_SEEK_SET, -1,
1591 "-*- texinfo -*-\n\ 1614 "-*- texinfo -*-\n\