Changeset 992 for trunk/base
- Timestamp:
- Oct 8, 2002, 11:19:42 AM (22 years ago)
- Location:
- trunk/base/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/base/src/pextlib1.0/Pextlib.c
r816 r992 261 261 } 262 262 263 /* XXX: cannot set eof > 2GB */ 264 int FtruncateCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) 265 { 266 int fd, ret; 267 long eof = 0; 268 char *res; 269 Tcl_Channel channel; 270 ClientData handle; 271 272 if (objc > 3) { 273 Tcl_WrongNumArgs(interp, 1, objv, "channelId eof"); 274 return TCL_ERROR; 275 } 276 277 if ((channel = Tcl_GetChannel(interp, Tcl_GetString(objv[1]), NULL)) == NULL) 278 return TCL_ERROR; 279 280 if (Tcl_GetChannelHandle(channel, TCL_READABLE|TCL_WRITABLE, &handle) != TCL_OK) { 281 Tcl_SetResult(interp, "error getting channel handle", TCL_STATIC); 282 return TCL_ERROR; 283 } 284 fd = (int) handle; 285 286 if (Tcl_GetLongFromObj(interp, objv[2], &eof) != TCL_OK) { 287 return TCL_ERROR; 288 } 289 290 if ((ret = ftruncate(fd, eof)) != 0) 291 { 292 switch(errno) { 293 case EBADF: 294 res = "EBADF"; 295 break; 296 case EINVAL: 297 res = "EINVAL"; 298 break; 299 default: 300 res = strerror(errno); 301 break; 302 } 303 Tcl_SetResult(interp, (void *) res, TCL_STATIC); 304 return TCL_ERROR; 305 } 306 return TCL_OK; 307 } 308 263 309 int ReaddirCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) 264 310 { … … 345 391 Tcl_CreateObjCommand(interp, "system", SystemCmd, NULL, NULL); 346 392 Tcl_CreateObjCommand(interp, "flock", FlockCmd, NULL, NULL); 393 Tcl_CreateObjCommand(interp, "ftruncate", FtruncateCmd, NULL, NULL); 347 394 Tcl_CreateObjCommand(interp, "readdir", ReaddirCmd, NULL, NULL); 348 395 Tcl_CreateObjCommand(interp, "strsed", StrsedCmd, NULL, NULL); -
trunk/base/src/port1.0/portutil.tcl
r989 r992 325 325 seek $input 0 326 326 327 if {[catch {exec cat <@$output >@$input 2>/dev/null} error]} { 327 # copy from strsed output back into the input 328 if {[catch {fcopy $output $input} error]} { 328 329 ui_error "reinplace: $error" 329 330 close $output … … 332 333 return -code error "reinplace failed" 333 334 } 335 336 set eof [file size "$tmpfile"] 337 puts "$tmpfile $eof" 338 ftruncate $input $eof 334 339 335 340 close $output
Note: See TracChangeset
for help on using the changeset viewer.