X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Q0pJ7d0s+MMnfs4YsN8ujiqV+V0CuBLxyfG5cUtVJfI=; b=l6SJvVAPCGzZwbZJEtCMBhzF8dtIu4a961IStq8IfZZAktgugg1rVIrEdLbk961Jyg /l/i8otANB69jivFj5ZKOpAShRHd7jP6RNKRqEYBG5Canfcz+r70qHMQBQk7jipF7KXh X10Iz3anB5coyvU6DK9SRZ2TxhtlzDzUj7tWrzxF7rIsznTV/+R0PQt4R9FenWlXJ1c0 +VwxfTrldtLJYfT1irrilv3Wm+A0S9XCFp0u1cO2q8yLKg4bUfZoUI8RGdebORwOY/AJ +YUV57oxf8NKw7ekEdZN2ee7xcnJHsiJe+BA/CVZ1c7fRxgWoYbU317GwqOtTTJmLldR xSWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=Q0pJ7d0s+MMnfs4YsN8ujiqV+V0CuBLxyfG5cUtVJfI=; b=bMG2YIRlZrmksgplxRQd+46hnke8+YyClHWVxN/fymd/eQXnXREAo4p4CXkxdt2sxL rzB/tL3PirqnamWChFj/MJJ6SNmwqzvx1G+stmPMljA/nG65clvtjGENcqJk6w608BK3 NXoj4H7dRUVk27rSP6DLc1hShwX+Gy/X78xvc2OO1OgkSMfIIo5ZoYgwYxq3hskKMqlJ OOg3xTMB5jEVMrRbM8ablOKw/UNhNE8FpVKFhEWrlVBY1fa/axoqK2hTstXg4sEdklGB 6/g16TuFy+lp4Dq0fInZs/0WwJAnxufY/9EqvYBnKytN0V5OWcpVf8F+4rZjXmpDNFHO 6+gw== X-Gm-Message-State: AIkVDXJ1hu7QD8PNy2LJFvLZ9idci9AuMGhoZt4MX3hb8a4ilkltJE3T3JMKhEqcgVYn/+PSRr/sLD8h9nw5Fw== X-Received: by 10.36.215.70 with SMTP id y67mr2563098itg.16.1482243970749; Tue, 20 Dec 2016 06:26:10 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <97c92faf-c9df-4ccf-85f9-d10ab659a8c4@googlegroups.com> References: <97c92faf-c9df-4ccf-85f9-d10ab659a8c4 AT googlegroups DOT com> From: "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]" Date: Tue, 20 Dec 2016 17:26:09 +0300 Message-ID: Subject: Re: DJGPP problem with getting file size via fstat or not implemented yet? To: djgpp AT delorie DOT com Content-Type: text/plain; charset=UTF-8 Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 12/20/16, RayeR (glaux AT centrum DOT cz) [via djgpp AT delorie DOT com] wrote: > Hi, I compiled the Wavpack lossless codec tool and found a problem in > function DoGetFileSize() that on unix systems use this code: > > struct stat statbuf; > > if (!hFile || fstat (fileno (hFile), &statbuf) || !(statbuf.st_mode & > S_IFREG)) > return 0; > > return (int64_t) statbuf.st_size; > > The problem is that it returns zero. The problem is not with fstat(): break that if construct into smaller pieces and check every step, and you shall see that it is the S_IFREG check on st_mode which is failing. Djgpp defines S_IFREG as 0x0000, so it is no miracle that it fails. Replace !(statbuf.st_mode & S_IFREG) with !S_ISREG(statbuf.st_mode) and it shall work. > So I used lfilelength(fileno(hFile) > function that works. Does it mean that there's a bug in fstat or it is not > implemented at all (just a dummy)? Does lfilelength() supports >2GB files on > enabled filesystems (like NTFS under NTVDM)?