[GH-ISSUE #127] Negative filesize on ARMv7 for files over 2GB #88

Closed
opened 2026-03-02 15:55:41 +03:00 by kerem · 4 comments
Owner

Originally created by @dausruddin on GitHub (Feb 19, 2019).
Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/127

I have a couple of files over 2GB in size and they are displayed with negative size.
After reading some sources, turned out filesize() doesn't work well with 32-bit system for files bigger than 2GB.

I found some functions to replace filesize() that will work, but I am not sure if it is a good idea for me to edit the code by myself. Maybe you know the best method to use.

Thanks.

Originally created by @dausruddin on GitHub (Feb 19, 2019). Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/127 I have a couple of files over 2GB in size and they are displayed with negative size. After reading some sources, turned out filesize() doesn't work well with 32-bit system for files bigger than 2GB. I found some functions to replace filesize() that will work, but I am not sure if it is a good idea for me to edit the code by myself. Maybe you know the best method to use. Thanks.
kerem 2026-03-02 15:55:41 +03:00
Author
Owner

@prasathmani commented on GitHub (Feb 28, 2019):

Fixed

<!-- gh-comment-id:468214295 --> @prasathmani commented on GitHub (Feb 28, 2019): [Fixed](https://github.com/prasathmani/tinyfilemanager/commit/da31717cff67424c4a85c60e18ea663ebfe77081)
Author
Owner

@dausruddin commented on GitHub (Mar 3, 2019):

Hi. Looking into the commit, you just added support for Windows but Linux will still be using filesize.

function fm_get_size($file)
{
    $return = filesize($file);
    if(substr(PHP_OS, 0, 3) == "WIN") {
        exec('for %I in ("'.$file.'") do @echo %~zI', $output);
        $return = $output[0];
    }
    return $return;
}

The code clearly would just be checking for a Windows and use specific method, but then if Linux, it would still be using filesize().

I have tried searching a solution by myself and found this solution works: https://stackoverflow.com/a/5502328

<!-- gh-comment-id:468990291 --> @dausruddin commented on GitHub (Mar 3, 2019): Hi. Looking into the commit, you just added support for Windows but Linux will still be using `filesize`. ``` function fm_get_size($file) { $return = filesize($file); if(substr(PHP_OS, 0, 3) == "WIN") { exec('for %I in ("'.$file.'") do @echo %~zI', $output); $return = $output[0]; } return $return; } ``` The code clearly would just be checking for a Windows and use specific method, but then if Linux, it would still be using filesize(). I have tried searching a solution by myself and found this solution works: https://stackoverflow.com/a/5502328
Author
Owner

@prasathmani commented on GitHub (Mar 3, 2019):

@psycholyzern your suggestion is added now. check now.

<!-- gh-comment-id:469007287 --> @prasathmani commented on GitHub (Mar 3, 2019): @psycholyzern your suggestion is added now. check now.
Author
Owner

@dausruddin commented on GitHub (Mar 13, 2019):

Thanks :)

<!-- gh-comment-id:472517393 --> @dausruddin commented on GitHub (Mar 13, 2019): Thanks :)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tinyfilemanager#88
No description provided.