Browse Source

write to file, read from file

221V 1 week ago
parent
commit
493b321eb0
1 changed files with 22 additions and 1 deletions
  1. 22 1
      vtest/source/app.d

+ 22 - 1
vtest/source/app.d

@@ -18,13 +18,13 @@ import memcached_test : memcached_test; // memcached example
 import mutex_test : init_mutex, ws_mutex_handle; // mutex example
 import mutex_test : init_mutex, ws_mutex_handle; // mutex example
 
 
 
 
+import std.stdio : writeln, File;
 import std.string;
 import std.string;
 import std.array;
 import std.array;
 import std.algorithm;
 import std.algorithm;
 import std.variant : Variant;
 import std.variant : Variant;
 
 
 
 
-
 import std.datetime : SysTime, Clock;
 import std.datetime : SysTime, Clock;
 import std.concurrency : spawn;
 import std.concurrency : spawn;
 import vibe.core.concurrency;
 import vibe.core.concurrency;
@@ -277,6 +277,27 @@ void main(){
   
   
   
   
   
   
+  // write to file, read from file
+  auto file = File("test.txt", "w");
+  //file.write("hello");
+  file.writeln("hello");
+  file.writeln("world");
+  file.writeln("test777");
+  file.close();
+  file.open("test.txt", "r");
+  while(!file.eof()){
+    string line = strip( file.readln() );
+    writeln("read line -> |", line);
+  }
+  /*
+read line -> |hello
+read line -> |world
+read line -> |test777
+read line -> |
+  */
+  
+  
+  
   /*
   /*
   user_state_pid = spawn(&startCleanupTask2); // worker - clean inactive user state -- with message passing (actors model like in Erlang) -- err here - do not tick every 30 sec
   user_state_pid = spawn(&startCleanupTask2); // worker - clean inactive user state -- with message passing (actors model like in Erlang) -- err here - do not tick every 30 sec
   spawn(&startCleanupTask21); // daemon for worker
   spawn(&startCleanupTask21); // daemon for worker