Return-Path: lccheung@usc.edu Delivery-Date: Mon Sep 8 16:16:49 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,HTML_MESSAGE autolearn=ham version=3.2.3 Received: from msg-scanner2.usc.edu (msg-scanner2.usc.edu [128.125.137.211]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id m88NGnb6028229 for ; Mon, 8 Sep 2008 16:16:49 -0700 Received: from msg-mx2.usc.edu ([128.125.137.7]) by msg-scanner2.usc.edu (Sun Java System Messaging Server 6.2-3.04 (built Jul 15 2005)) with ESMTP id <0K6W004GSGPY5660@msg-scanner2.usc.edu> for cs551@merlot.usc.edu; Mon, 08 Sep 2008 16:19:44 -0700 (PDT) Received: from wf-out-1314.google.com (wf-out-1314.google.com [209.85.200.169]) by msg-mx2.usc.edu (Postfix) with ESMTP id 7B0392D6F for ; Mon, 08 Sep 2008 16:19:41 -0700 (PDT) Received: by wf-out-1314.google.com with SMTP id 28so1880312wfa.27 for ; Mon, 08 Sep 2008 16:19:41 -0700 (PDT) Received: by 10.142.232.20 with SMTP id e20mr5490111wfh.109.1220915981253; Mon, 08 Sep 2008 16:19:41 -0700 (PDT) Received: by 10.142.158.11 with HTTP; Mon, 08 Sep 2008 16:19:41 -0700 (PDT) Date: Mon, 08 Sep 2008 16:19:41 -0700 From: Leslie Cheung Subject: Re: Stat(1) for filesize In-reply-to: <200809080153.m881rH8X021678@bourbon.usc.edu> To: cs551@merlot.usc.edu Message-id: MIME-version: 1.0 Content-type: multipart/alternative; boundary="----=_Part_6764_6898909.1220915981250" References: <200809080153.m881rH8X021678@bourbon.usc.edu> ------=_Part_6764_6898909.1220915981250 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi class, fseek and stat are different, in that fseek reads the file while stat does not (stat reads only the file's metadata). If you do not have read permission, fseek would fail, but stat may give you the filesize if you have permission to read the file's metadata. I have just looked at the grading guidelines, and you can't get the filesize using fseek in at least one test case. Regards, Leslie On Sun, Sep 7, 2008 at 6:53 PM, Bill Cheng wrote: > Someone wrote: > > > You have emphasized to use stat(1) for filesize. But I have used other > > method such as 'Fseek' to know the filesize. Is that ok? Or should I > > change it? > > Anything equivalent would be fine. Please make sure that the > value it gives is correct and that it also works for directories. > -- > Bill Cheng // bill.cheng@usc.edu > > ------=_Part_6764_6898909.1220915981250 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline
Hi class,
 
fseek and stat are different, in that fseek reads the file while stat does not (stat reads only the file's metadata).  If you do not have read permission, fseek would fail, but stat may give you the filesize if you have permission to read the file's metadata.
 
I have just looked at the grading guidelines, and you can't get the filesize using fseek in at least one test case.
 
Regards,
Leslie

On Sun, Sep 7, 2008 at 6:53 PM, Bill Cheng <william@bourbon.usc.edu> wrote:
Someone wrote:

 > You have emphasized to use stat(1) for filesize. But I have used other
 > method such as 'Fseek' to know the filesize. Is that ok? Or should I
 > change it?

Anything equivalent would be fine.  Please make sure that the
value it gives is correct and that it also works for directories.
--
Bill Cheng // bill.cheng@usc.edu <URL:http://merlot.usc.edu/william/usc/>


------=_Part_6764_6898909.1220915981250--