Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Output #50

Open
nyttimangus opened this issue Apr 5, 2014 · 9 comments
Open

File Output #50

nyttimangus opened this issue Apr 5, 2014 · 9 comments

Comments

@nyttimangus
Copy link

File Output seems to be non-existent in 3.2.1. I can't create a file with openFileOutPut() or edit a file with openFileOutPut(). With the same code I can manipulate files in 3.1.

@swordmaster2k
Copy link
Member

Please post some sample code.

Thanks.

@nyttimangus
Copy link
Author

//This doesn't work (new file)
openFileOutput("ATextDocument.txt", "Misc"); //This should create a new file
filePut("ATextDocument.txt", "How do you do?"); //NOTE: Only writes the H
filePrint("ATextDocument.txt", "ow do you do?") //Writes the whole line
closeFile("ATextDocument.txt"); //Closes the file
//^^Check this by seeing whether "ATextDocument.txt" exists in the "Misc" folder (make sure to show all file types)

//Nor does this work (pre-existent file)
openFileOutput("start.tem", "Chrs"); //This should erase the file
filePut("start.tem", "How do you do?"); //NOTE: Only writes the H
filePrint("start.tem", "ow do you do?") //Writes the whole line
closeFile("start.tem"); //Closes the file
//^^Check these results by opening "start.tem" with notepad

//This works fine though
openFileInput("start/start_defend.anm", "Misc");
debugger(fileInput("start/start_defend.anm"));
closeFile("start/start_defend.anm");

@swordmaster2k
Copy link
Member

This bug is being flagged with the highest priority.

First to be investigated...

@swordmaster2k
Copy link
Member

Issue appears to be in CFile.cpp, while the data is being put into the memory i.e. "How do you do?" it is never actually wrote out before the file is closed.

Should be easy to resolve.

@swordmaster2k
Copy link
Member

Please clarify the following in the example below:

  • Step 1: If ATextDocument.txt does not a first exist the engine should create it.
  • Step 2: If ATextDocument.txt does exist it should open the existing version and overwrite the data.
  • Step 3: If ATextDocument.txt does exist it should read the contents of the file.

The result should be "Hello space!".

// Step 1: 
openFileOutput("ATextDocument.txt", "Misc"); 
filePrint("ATextDocument.txt", "Hello world!") ;
closeFile("ATextDocument.txt"); 

// Step 2:
openFileOutput("ATextDocument.txt", "Misc");
filePrint("ATextDocument.txt", "Hello space!"); 
closeFile("ATextDocument.txt");

// Step 3:
openFileInput("ATextDocument.txt", "Misc");
debugger(fileInput("ATextDocument.txt"));
closeFile("ATextDocument.txt");

@nyttimangus
Copy link
Author

Presuming that is directed at me, that is correct. That is how the code should behave.

@swordmaster2k
Copy link
Member

I ran some more tests against the fix and file I/O from my limited results it is working, I just forgot to ensure files are opened for writing as well as reading when open is called on them.

Closed.

@nyttimangus
Copy link
Author

Ok. I finally got around to actually testing this, and the "Step 2" above does not actually overwrite the file. Reading and writing seem to work fine, but overwriting does not work.

@swordmaster2k
Copy link
Member

Minor issue, I'll correct it over the coming days.

@swordmaster2k swordmaster2k reopened this Dec 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants