Re: Writing to file problem (Kernelbase exeption)

2014-06-05 Thread Kagamin via Digitalmars-d-learn
Try to reduce it: remove code from the program piece by piece 
until you find a fragment, which causes the problem.


Re: Writing to file problem (Kernelbase exeption)

2014-06-05 Thread Konrad via Digitalmars-d-learn

Well, there is a problem with
config_file.write(info);

but when I'm changing it to
write(Data/config.ini, info);
(as it states in http://dlang.org/phobos/std_file.html#.write) 
I'm getting an error of conflict between std.stdio.write and 
std.file.write. That's why I was using the first line.


Is there any way to solve this problem?

Best regards,
Ironus


Re: Writing to file problem (Kernelbase exeption)

2014-06-05 Thread Stefan Koch via Digitalmars-d-learn

config_file needs to be the string
not a struct File
.


Re: Writing to file problem (Kernelbase exeption)

2014-06-05 Thread Konrad via Digitalmars-d-learn

Right now I have:

import file = std.file;
import std.stdio;

int game_change_config(string _player_spritesheet, string 
_flame_spritesheet) {

   string info = _player_spritesheet~\n~_flame_spritesheet;
   char[] info_table;
   for(int i = 0; i  info.length; i++) {
  info_table.length++;
  info_table[info_table.length - 1] = info[i];
   }
   file.write(Data/config.ini, info_table); 
   return 0;
}

I'm changing my string into dynamic char array and I'm using 
Data/config.ini as a string, just as Stefan Koch suggested. 
Everything compiles and my function doesn't return any errors 
while working, but it's not changing my file content (it's still 
as same as before running a function).


Any solutions? I'm starting to get pretty angry about that 
problem (more complicated stuff is working fine and that one part 
can't)...


Best regards,
Ironus


Re: Writing to file problem (Kernelbase exeption)

2014-06-05 Thread Ali Çehreli via Digitalmars-d-learn

On 06/05/2014 01:39 PM, Konrad wrote: Right now I have:

 import file = std.file;
 import std.stdio;

 int game_change_config(string _player_spritesheet, string
 _flame_spritesheet) {
 string info = _player_spritesheet~\n~_flame_spritesheet;
 char[] info_table;
 for(int i = 0; i  info.length; i++) {
info_table.length++;
info_table[info_table.length - 1] = info[i];

That is not necessary, a simple concatenation would be the equivalent:

info_table ~= info[i];// instead of the previous two lines

 }
 file.write(Data/config.ini, info_table);

Random guess: Try with full path and see whether that helps. How about 
file access rights? Can you write to that file by other means?


Ali



Re: Writing to file problem (Kernelbase exeption)

2014-06-05 Thread Konrad via Digitalmars-d-learn
Ok, I have rebuilded whole solution in MSVS (I'm using VisualD 
plugin) and everything started to work with my previously pasted 
code.


@Ali, thank you for advise with concatenation, I haven't thought 
about that.


Also thank you to all of you, guys, all that you wrote was very 
helpfull.


Best regards,
Ironus