comparison src/file-io.cc @ 3202:44d82b369c78

[project @ 1998-10-29 20:27:57 by jwe]
author jwe
date Thu, 29 Oct 1998 20:28:02 +0000
parents c17387059fd3
children 041ea33fbbf4
comparison
equal deleted inserted replaced
3201:72bb6379d8a3 3202:44d82b369c78
878 oct_data_conv::data_type dt 878 oct_data_conv::data_type dt
879 = oct_data_conv::string_to_data_type (prec); 879 = oct_data_conv::string_to_data_type (prec);
880 880
881 if (! error_state) 881 if (! error_state)
882 { 882 {
883 double dskip = skip_arg.double_value (); 883 int skip = skip_arg.int_value (true);
884 884
885 if (! error_state) 885 if (! error_state)
886 { 886 {
887 if (D_NINT (dskip) == dskip) 887 string arch = arch_arg.string_value ();
888
889 if (! error_state)
888 { 890 {
889 int skip = NINT (dskip); 891 oct_mach_info::float_format flt_fmt
890 892 = oct_mach_info::string_to_float_format (arch);
891 string arch = arch_arg.string_value ();
892 893
893 if (! error_state) 894 if (! error_state)
894 { 895 retval = os.read (size, dt, skip, flt_fmt, count);
895 oct_mach_info::float_format flt_fmt
896 = oct_mach_info::string_to_float_format (arch);
897
898 if (! error_state)
899 retval = os.read (size, dt, skip, flt_fmt, count);
900 }
901 else
902 ::error ("fread: architecture type must be a string");
903 } 896 }
904 else 897 else
905 ::error ("fread: skip must be an integer"); 898 ::error ("fread: architecture type must be a string");
906 } 899 }
907 else 900 else
908 ::error ("fread: invalid skip specified"); 901 ::error ("fread: skip must be an integer");
909 } 902 }
910 else 903 else
911 ::error ("fread: invalid data type specified"); 904 ::error ("fread: invalid data type specified");
912 } 905 }
913 else 906 else
1020 oct_data_conv::data_type dt 1013 oct_data_conv::data_type dt
1021 = oct_data_conv::string_to_data_type (prec); 1014 = oct_data_conv::string_to_data_type (prec);
1022 1015
1023 if (! error_state) 1016 if (! error_state)
1024 { 1017 {
1025 double dskip = skip_arg.double_value (); 1018 int skip = skip_arg.int_value (true);
1026 1019
1027 if (! error_state) 1020 if (! error_state)
1028 { 1021 {
1029 if (D_NINT (dskip) == dskip) 1022 string arch = arch_arg.string_value ();
1023
1024 if (! error_state)
1030 { 1025 {
1031 int skip = NINT (dskip); 1026 oct_mach_info::float_format flt_fmt
1032 1027 = oct_mach_info::string_to_float_format (arch);
1033 string arch = arch_arg.string_value ();
1034 1028
1035 if (! error_state) 1029 if (! error_state)
1036 { 1030 retval = os.write (data, dt, skip, flt_fmt);
1037 oct_mach_info::float_format flt_fmt
1038 = oct_mach_info::string_to_float_format (arch);
1039
1040 if (! error_state)
1041 retval = os.write (data, dt, skip, flt_fmt);
1042 }
1043 else
1044 ::error ("fwrite: architecture type must be a string");
1045 } 1031 }
1046 else 1032 else
1047 ::error ("fwrite: skip must be an integer"); 1033 ::error ("fwrite: architecture type must be a string");
1048 } 1034 }
1049 else 1035 else
1050 ::error ("fwrite: invalid skip specified"); 1036 ::error ("fwrite: skip must be an integer");
1051 } 1037 }
1038 else
1039 ::error ("fwrite: invalid precision specified");
1052 } 1040 }
1053 else 1041 else
1054 ::error ("fwrite: precision must be a string"); 1042 ::error ("fwrite: precision must be a string");
1055 1043
1056 return retval; 1044 return retval;
1339 1327
1340 int status = 0; 1328 int status = 0;
1341 1329
1342 if (args.length () == 1) 1330 if (args.length () == 1)
1343 { 1331 {
1344 double dmask = args(0).double_value (); 1332 int mask = args(0).int_value (true);
1345 1333
1346 if (error_state) 1334 if (! error_state)
1335 {
1336 if (mask < 0)
1337 {
1338 status = -1;
1339 ::error ("umask: MASK must be a positive integer value");
1340 }
1341 else
1342 {
1343 int oct_mask = convert (mask, 8, 10);
1344
1345 if (! error_state)
1346 status = convert (file_ops::umask (oct_mask), 10, 8);
1347 }
1348 }
1349 else
1347 { 1350 {
1348 status = -1; 1351 status = -1;
1349 ::error ("umask: expecting integer argument"); 1352 ::error ("umask: expecting integer argument");
1350 }
1351 else
1352 {
1353 int mask = NINT (dmask);
1354
1355 if (mask != dmask || mask < 0)
1356 {
1357 status = -1;
1358 ::error ("umask: MASK must be a positive integer value");
1359 }
1360 else
1361 {
1362 int oct_mask = convert (mask, 8, 10);
1363
1364 if (! error_state)
1365 status = convert (file_ops::umask (oct_mask), 10, 8);
1366 }
1367 } 1353 }
1368 } 1354 }
1369 else 1355 else
1370 print_usage ("umask"); 1356 print_usage ("umask");
1371 1357