March 07, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7659

           Summary: Reopen a file
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: bioinfornatics@gmail.com


--- Comment #0 from bioinfornatics <bioinfornatics@gmail.com> 2012-03-07 09:09:05 PST ---
Dear,
when you want to reopen a closed file from a File instance the programm
segfault, i.e above code

_________________________________
import std.stdio;
import std.string;

void main(){
    File f = File("text.txt", "w");
    f.writeln( "blah" );
    f.close();
    if( ! f.isOpen )
        f = File( f.name, "a+" );
    f.writeln( "blah" );
    f.close();
}
_________________________________


this tniny code segfault because when you close a file you can't after get the filer name closed by using f.name

it will really helpfull to know at any moment the name from a File instance. And method isOpen will get more sense to use. Because currently it said if isopen or not but can't do many thing in more.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7659


SomeDude <lovelydear@mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear@mailmetrash.com
         Depends on|                            |7022


--- Comment #1 from SomeDude <lovelydear@mailmetrash.com> 2012-04-21 01:40:31 PDT ---
The issue here is f.close() erases f.name, making it impossible to reopen f by name; unless it's stored in a separate variable.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7659


1100110 <10equals2@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |10equals2@gmail.com


--- Comment #3 from 1100110 <10equals2@gmail.com> 2012-06-21 18:39:15 PDT ---
I encountered this bug, or a similar variant.

I can't decide if I just won the lottery, or if it's reproducable... I couldn't reproduce it, but I might be missing something important. All of my attempts simply segfaulted.

This code immediately exits the function with no errors.
It returns the correct value even though I assume the return statement is never
reached since nothing around the return statement will execute.
try
{
  auto f = File(fileName, "w");
  f.write("success");
  f.detach;
  if(true)
  {
     f = File(fileName, "w");
     if(f.readln() == "success")
     success = true;
  }
  f.close;
///All of these cause it to immediately exit the current func.
  f.name;
  writeln(f.name);
  f.name.remove;
}

The catch statement also catches no Exceptions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7659



--- Comment #4 from 1100110 <10equals2@gmail.com> 2012-06-21 18:41:39 PDT ---
I encountered this bug, or a similar variant.

I can't decide if I just won the lottery, or if it's reproducable... I couldn't reproduce it, but I might be missing something important. All of my attempts simply segfaulted.

This code immediately exits the function with no errors.
It returns the correct value even though I assume the return statement is never
reached since nothing around the return statement will execute.
try
{
  auto f = File(fileName, "w");
  f.write("success");
  f.detach;
  if(true)
  {
     f = File(fileName, "r");
     if(startsWith(f.readln(), "success"))
         success = true;
  }
  f.close;
///All of these cause it to immediately exit the current func.
  f.name;
  writeln(f.name);
  f.name.remove;
}

The catch statement also catches no Exceptions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 22, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7659



--- Comment #5 from 1100110 <10equals2@gmail.com> 2012-06-21 18:43:01 PDT ---
I encountered this bug, or a similar variant.

I can't decide if I just won the lottery, or if it's reproducable... I couldn't reproduce it, but I might be missing something important. All of my attempts simply segfaulted.

This code immediately exits the function with no errors.
It returns the correct value even though I assume the return statement is never
reached since nothing around the return statement will execute.
try
{
  auto f = File(fileName, "w");
  f.write("success");
  f.detach;
  if(true)
  {
     f = File(fileName, "r");
     if(startsWith(f.readln(), "success"))
         success = true;
  }
  f.close;
///All of these cause it to immediately exit the current func.
  f.name;
  writeln(f.name);
  f.name.remove;
}

The catch statement also catches no Exceptions.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 04, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7659



--- Comment #6 from github-bugzilla@puremagic.com 2012-10-04 09:51:22 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/84a6468ef86ebdb94d1430d95ea8d9964f8e85bf Fix Issue 7659 - std.stdio.File.close() erases file.name

* also improve documentation a bit

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 07, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=7659


Mike Wey <mike-wey@planet.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |mike-wey@planet.nl
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home