dMZX Forums: Restore FREAD_LENGTH and FWRITE_LENGTH counters -> Archived Requests -> Tracker

Jump to content

Report ID 761 Title Restore FREAD_LENGTH and FWRITE_LENGTH counters
Product Archived Requests Status Implemented (Severity 1 - Low)
Version 2.92 Fixed in 2.92

Page 1 of 1
  • Cannot start a new Issue
  • Closed Issue This issue is locked

Report ID #761: Restore FREAD_LENGTH and FWRITE_LENGTH counters

#1 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,904
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 13 March 2019 - 11:51 PM

Only found out about these counters recently since they aren't documented in counter.c with the rest of the counters that were removed with no compatibility layer. Essentially, these counters would return the length of the input file or directory and the (current) length of the output file, if open.

These counters were added in MZX 2.6, commented out in MZX 2.65 apparently due to them not working correctly, and then removed altogether in the port. They do not appear to have been documented in the changelog ever, and were easy to miss in the help file (where they were documented until 2.81) and probably went unused when they did exist due to bad color coding.

  // Don't think anyone was using these and they're crippled
  // anyway. - Exo

  /*    if(!str_cmp(name,"FREAD_LENGTH"))
    {
      if(input_file == NULL) return -1;
      return filelength(fileno(input_file));
    }

    if(!str_cmp(name,"FWRITE_LENGTH"))
    {
      if(output_file == NULL) return -1;
      return filelength(fileno(output_file));
    } */


Posted Image

A short discussion in the old request thread showing how ugly and hackish the current method of reading a file into a string currently is.

A fixed version of Exo's code in these posts:
set "blah.txt" "fread_open"
set "fread_pos" -1
set "file_size" "fread_pos"
set "fread_pos" 0
set "$string" "fread&file_size&"


This construct, which as a user who does this a lot I can say is really annoying, could be replaced with the much more legible and user-friendly
set "blah.txt" "fread_open"
set "$string" "fread&fread_length&"


The fread version can use either fstat or ftell/fseek, but the fwrite version needs ftell/fseek since the file will probably have changes that haven't been flushed.
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository


Page 1 of 1  
  • Cannot start a new Issue
  • Closed Issue This issue is locked

Replies (1 - 2)

#2 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,904
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 15 March 2019 - 05:11 AM

Updating status to: Implemented
Updating severity to: 1 - Low
Issue fixed in: 2.92

Implemented in GIT da5cd407 in the master-2.92 branch.
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#3 User is offline  
Terryn 

  • ******
  • Group: DigiStaff
  • Posts: 2,961
  • Joined: 12-October 00
  • Gender:Male

Posted 23 July 2019 - 12:29 AM

Moving to: Archived Requests


Page 1 of 1
  • Cannot start a new Issue
  • Closed Issue This issue is locked

1 User(s) are reading this issue
1 Guests and 0 Anonymous Users


Powered by IP.Tracker 1.3.2 © 2024  IPS, Inc.