Milan Vandrovec created FLEX-33560:
--------------------------------------

             Summary: FileStream position is updated incorrectly in 
FileMode.APPEND mode
                 Key: FLEX-33560
                 URL: https://issues.apache.org/jira/browse/FLEX-33560
             Project: Apache Flex
          Issue Type: Bug
    Affects Versions: Adobe Flex SDK 3.6 (Release)
         Environment: 1. in debugger of FlexBuilder 3
2. compiled, with AIR 3.6.0, 3.7.0
            Reporter: Milan Vandrovec


When writing to a FileStream so that the new position would be a multiple of 
4096, the position is increased twice (writing a byte advances from 4095 to 
4097, writing 512 bytes advances from 3584 to 4608).

Sample code:
    var cnt: int;
    var logfile: File=new File("c:/demo.txt");
    var logstream: FileStream=new FileStream();
    logstream.open(logfile, FileMode.WRITE);
    logstream.close();
    logstream.open(logfile, FileMode.APPEND);
    for (cnt=0; cnt<4096-2; cnt++)
      logstream.writeByte(0x41);
    trace(logstream.position);
    logstream.writeByte(0x42);
    trace(logstream.position);
    logstream.writeByte(0x43);
    trace(logstream.position);
    logstream.writeByte(0x44);
    trace(logstream.position);
    logstream.close();
    
    var x512: ByteArray=new ByteArray();
    for (cnt=0; cnt<512; cnt++)
      x512.writeByte(0x41);
    x512.position=0;
    logstream.open(logfile, FileMode.WRITE);
    logstream.close();
    logstream.open(logfile, FileMode.APPEND);
    for (cnt=0; cnt<7; cnt++)
      logstream.writeBytes(x512);
    trace(logstream.position);                     //now at 4096-512
    logstream.writeBytes(x512);
    trace(logstream.position);                     //now at 4096+512
    logstream.close();

Actual output:
4094
4095
4097
4098
---
3584
4608

Expected output:
4094
4095
4096
4097
---
3584
4096


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to