comparison src/syscalls.cc @ 5476:941f0fc6b596

[project @ 2005-09-29 22:46:07 by jwe]
author jwe
date Thu, 29 Sep 2005 22:49:43 +0000
parents ec44bd0917fe
children 8b0b36c2dc0c
comparison
equal deleted inserted replaced
5475:04fa51cb7e90 5476:941f0fc6b596
65 { 65 {
66 Octave_map m; 66 Octave_map m;
67 67
68 m.assign ("dev", static_cast<double> (fs.dev ())); 68 m.assign ("dev", static_cast<double> (fs.dev ()));
69 m.assign ("ino", fs.ino ()); 69 m.assign ("ino", fs.ino ());
70 m.assign ("mode", fs.mode ());
70 m.assign ("modestr", fs.mode_as_string ()); 71 m.assign ("modestr", fs.mode_as_string ());
71 m.assign ("nlink", fs.nlink ()); 72 m.assign ("nlink", fs.nlink ());
72 m.assign ("uid", fs.uid ()); 73 m.assign ("uid", fs.uid ());
73 m.assign ("gid", fs.gid ()); 74 m.assign ("gid", fs.gid ());
74 #if defined (HAVE_STRUCT_STAT_ST_RDEV) 75 #if defined (HAVE_STRUCT_STAT_ST_RDEV)
708 @item dev\n\ 709 @item dev\n\
709 ID of device containing a directory entry for this file.\n\ 710 ID of device containing a directory entry for this file.\n\
710 \n\ 711 \n\
711 @item ino\n\ 712 @item ino\n\
712 File number of the file.\n\ 713 File number of the file.\n\
714 \n\
715 @item mode\n\
716 File mode, as an integer. Use the functions @code{S_ISREG},\n\
717 @code{S_ISDIR}, @code{S_ISCHR}, @code{S_ISBLK}, @code{S_ISFIFO},\n\
718 @code{S_ISLNK}, or @code{S_ISSOCK} to extract information from this\n\
719 value.\n\
713 \n\ 720 \n\
714 @item modestr\n\ 721 @item modestr\n\
715 File mode, as a string of ten letters or dashes as would be returned by\n\ 722 File mode, as a string of ten letters or dashes as would be returned by\n\
716 @kbd{ls -l}.\n\ 723 @kbd{ls -l}.\n\
717 \n\ 724 \n\
773 blksize = 4096\n\ 780 blksize = 4096\n\
774 mtime = 847219094\n\ 781 mtime = 847219094\n\
775 gid = 6\n\ 782 gid = 6\n\
776 nlink = 1\n\ 783 nlink = 1\n\
777 blocks = 768\n\ 784 blocks = 768\n\
785 mode = -rw-r--r--\n\
778 modestr = -rw-r--r--\n\ 786 modestr = -rw-r--r--\n\
779 ino = 9316\n\ 787 ino = 9316\n\
780 dev = 2049\n\ 788 dev = 2049\n\
781 @}\n\ 789 @}\n\
782 @result{} err = 0\n\ 790 @result{} err = 0\n\
813 print_usage ("stat"); 821 print_usage ("stat");
814 822
815 return retval; 823 return retval;
816 } 824 }
817 825
826 DEFUNX ("S_ISREG", FS_ISREG, args, ,
827 "-*- texinfo -*-\n\
828 @deftypefn {Built-in Function} {} S_ISREG (@var{mode})\n\
829 Return true if @var{mode} corresponds to a regular file. The value\n\
830 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\
831 @seealso{stat, lstat}\n\
832 @end deftypefn")
833 {
834 octave_value retval = false;
835
836 if (args.length () == 1)
837 {
838 double mode = args(0).double_value ();
839
840 if (! error_state)
841 retval = file_stat::is_reg (static_cast<mode_t> (mode));
842 else
843 error ("S_ISREG: invalid mode value");
844 }
845 else
846 print_usage ("S_ISREG");
847
848 return retval;
849 }
850
851 DEFUNX ("S_ISDIR", FS_ISDIR, args, ,
852 "-*- texinfo -*-\n\
853 @deftypefn {Built-in Function} {} S_ISDIR (@var{mode})\n\
854 Return true if @var{mode} corresponds to a directory. The value\n\
855 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\
856 @seealso{stat, lstat}\n\
857 @end deftypefn")
858 {
859 octave_value retval = false;
860
861 if (args.length () == 1)
862 {
863 double mode = args(0).double_value ();
864
865 if (! error_state)
866 retval = file_stat::is_dir (static_cast<mode_t> (mode));
867 else
868 error ("S_ISDIR: invalid mode value");
869 }
870 else
871 print_usage ("S_ISDIR");
872
873 return retval;
874 }
875
876 DEFUNX ("S_ISCHR", FS_ISCHR, args, ,
877 "-*- texinfo -*-\n\
878 @deftypefn {Built-in Function} {} S_ISCHR (@var{mode})\n\
879 Return true if @var{mode} corresponds to a character devicey. The value\n\
880 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\
881 @seealso{stat, lstat}\n\
882 @end deftypefn")
883 {
884 octave_value retval = false;
885
886 if (args.length () == 1)
887 {
888 double mode = args(0).double_value ();
889
890 if (! error_state)
891 retval = file_stat::is_chr (static_cast<mode_t> (mode));
892 else
893 error ("S_ISCHR: invalid mode value");
894 }
895 else
896 print_usage ("S_ISCHR");
897
898 return retval;
899 }
900
901 DEFUNX ("S_ISBLK", FS_ISBLK, args, ,
902 "-*- texinfo -*-\n\
903 @deftypefn {Built-in Function} {} S_ISBLK (@var{mode})\n\
904 Return true if @var{mode} corresponds to a block device. The value\n\
905 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\
906 @seealso{stat, lstat}\n\
907 @end deftypefn")
908 {
909 octave_value retval = false;
910
911 if (args.length () == 1)
912 {
913 double mode = args(0).double_value ();
914
915 if (! error_state)
916 retval = file_stat::is_blk (static_cast<mode_t> (mode));
917 else
918 error ("S_ISBLK: invalid mode value");
919 }
920 else
921 print_usage ("S_ISBLK");
922
923 return retval;
924 }
925
926 DEFUNX ("S_ISFIFO", FS_ISFIFO, args, ,
927 "-*- texinfo -*-\n\
928 @deftypefn {Built-in Function} {} S_ISFIFO (@var{mode})\n\
929 Return true if @var{mode} corresponds to a fifo. The value\n\
930 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\
931 @seealso{stat, lstat}\n\
932 @end deftypefn")
933 {
934 octave_value retval = false;
935
936 if (args.length () == 1)
937 {
938 double mode = args(0).double_value ();
939
940 if (! error_state)
941 retval = file_stat::is_fifo (static_cast<mode_t> (mode));
942 else
943 error ("S_ISFIFO: invalid mode value");
944 }
945 else
946 print_usage ("S_ISFIFO");
947
948 return retval;
949 }
950
951 DEFUNX ("S_ISLNK", FS_ISLNK, args, ,
952 "-*- texinfo -*-\n\
953 @deftypefn {Built-in Function} {} S_ISLNK (@var{mode})\n\
954 Return true if @var{mode} corresponds to a symbolic link. The value\n\
955 of @var{mode} is assumed to be returned from a call to @code{stat}.\n\
956 @seealso{stat, lstat}\n\
957 @end deftypefn")
958 {
959 octave_value retval = false;
960
961 if (args.length () == 1)
962 {
963 double mode = args(0).double_value ();
964
965 if (! error_state)
966 retval = file_stat::is_lnk (static_cast<mode_t> (mode));
967 else
968 error ("S_ISLNK: invalid mode value");
969 }
970 else
971 print_usage ("S_ISLNK");
972
973 return retval;
974 }
975
976 DEFUNX ("S_ISSOCK", FS_ISSOCK, args, ,
977 "-*- texinfo -*-\n\
978 @deftypefn {Built-in Function} {} S_ISSOCK (@var{mode})\n\
979 @seealso{stat, lstat}\n\
980 @end deftypefn")
981 {
982 octave_value retval = false;
983
984 if (args.length () == 1)
985 {
986 double mode = args(0).double_value ();
987
988 if (! error_state)
989 retval = file_stat::is_sock (static_cast<mode_t> (mode));
990 else
991 error ("S_ISSOCK: invalid mode value");
992 }
993 else
994 print_usage ("S_ISSOCK");
995
996 return retval;
997 }
998
818 DEFUN (unlink, args, , 999 DEFUN (unlink, args, ,
819 "-*- texinfo -*-\n\ 1000 "-*- texinfo -*-\n\
820 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} unlink (@var{file})\n\ 1001 @deftypefn {Built-in Function} {[@var{err}, @var{msg}] =} unlink (@var{file})\n\
821 Delete the file named @var{file}.\n\ 1002 Delete the file named @var{file}.\n\
822 \n\ 1003 \n\