Autor Beitrag
Sven
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 314


D6 Ent, K3 Pro (patched)
BeitragVerfasst: Fr 12.03.04 18:43 
Bevor jemand schreit: Ich habe gesucht, aber nichts gefunden.

Kann mir jemand eine Erklärung zu dem obigen Fehlercode geben? Kylix schweigt sich diesbezüglich in der Hilfe ziemlich aus.

Danke
Sven

_________________
MDK 9.1, Kernel 2.4.21, KDE 3.1 Kylix 3 Pro (patched), nutze aber auch Windows
tomtom62
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278

WIN 2000, XP prof
D5 prof.
BeitragVerfasst: Fr 12.03.04 18:53 
Bin nicht ganz sicher, aber 103 ist der Versuch, auf eine Datei zuzugreifen, die vorher nicht geöffnet war. Diese Meldungen kommen eigentlich nur noch vor, wenn man direkte Zugriffsfunktionen auf Dateien verwendet.
Sven Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 314


D6 Ent, K3 Pro (patched)
BeitragVerfasst: Fr 12.03.04 19:36 
Das wäre wirklich merkwürdig, da die Datei in jedem Fall geöffnet ist. Dieser Fehler tritt auch erst auf, wen ich die Datei mit CoseFile(f) schließe.

Ich muß dazu mal sagen, daß es sich um ein Kylix-Projekt handelt.

Es handelt sich dabei um das Schreiben einer temporären Datei.
Das ausführende Programm liegt in einem eigenem BIN-Verzeichnis und das temporäre Verzeichnis im selebn Wurzelverzeichnis:

Programmvereichnis
|
|-- BIN
|
|-- TMP

wenn ich aus dem Programm das temoräre Verzeichnis mit '../tmp/tempdatei.name' anspreche, dann gibt es die besagte Fehlermeldung. Wenn ich das '..' weglasse, wird das global Tempverzeichnis ausgewählt und es gibt keine Fehlermeldung.
Das will ich aber nicht.

_________________
MDK 9.1, Kernel 2.4.21, KDE 3.1 Kylix 3 Pro (patched), nutze aber auch Windows
Sven Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 314


D6 Ent, K3 Pro (patched)
BeitragVerfasst: Fr 12.03.04 19:39 
Ich habe gerade noch festgestellt, daß wenn ich die Prüfung mit IOResult fortlasse, funktioniert alles einwandfrei. Mmmmh :?

_________________
MDK 9.1, Kernel 2.4.21, KDE 3.1 Kylix 3 Pro (patched), nutze aber auch Windows
tomtom62
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278

WIN 2000, XP prof
D5 prof.
BeitragVerfasst: Fr 12.03.04 20:00 
Sven hat folgendes geschrieben:
wenn ich aus dem Programm das temoräre Verzeichnis mit '../tmp/tempdatei.name' anspreche, dann gibt es die besagte Fehlermeldung. Wenn ich das '..' weglasse, wird das global Tempverzeichnis ausgewählt und es gibt keine Fehlermeldung.
Das will ich aber nicht.


Zitat:
Delphi: File: Error: I/O Error 103

Cause:

A file is assigned and then closed, but the file pointer has not
(for all possible cases) been reset or rewritten, in between.

---

Solution:

Reset or rewrite the file pointer in all possible cases.

---

The source code with the problem looks like this:

procedure TForm1.PROCFileCreateNew( filenameS : string );
var fP : TextFile;
begin
AssignFile( fP, filenameS );
if FNFileCheckExistNotB( filenameS ) then begin
Reset( fP );
end;
Close( fP );
end;

Then the error occurs in Close( fP );

---

Solution:

You should in any case reset the file pointer (using 'reset'
or 'rewrite') between you 'assigned' the file until it reaches the
'close'.

E.g. like this:

procedure TForm1.PROCFileCreateNew( filenameS : string );
var fP : TextFile;
begin
AssignFile( fP, filenameS );
//
// so you also cover all other possibilities
// (like also in the other branch of the 'if')
// between assign and close
// by putting or a reset or a rewrite there
//
if FNFileCheckExistNotB( filenameS ) then begin
Rewrite( fP );
end
else begin
Reset( fP );
end;
Close( fP );
end;

----------------------------------------------------------------------

18 February 2004, 23:12. D Cooper

This can also be raised if you are trying to write out to a path that
does not exist. Example:

AssignFile(tout, 'nope:\blag\b.html');
Rewrite(tout);
WriteLn(tout, data);
CloseFile(tout);

----------------------------------------------------------------------


Das ist aus dem Internet, eventuell hilft es Dir weiter
Sven Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 314


D6 Ent, K3 Pro (patched)
BeitragVerfasst: Fr 12.03.04 20:11 
Erst habe ich
ausblenden Delphi-Quelltext
1:
2:
AssignFile(f, FileName);
Rewrite(f, 1);

geschrieben, dann kommt der Code zum schreiben der Daten und dann
ausblenden Delphi-Quelltext
1:
CloseFile(f);					

FileName ist kein leerer String.
Das Problem liegt bei den '..' im Dateinamen. Ich weiß nur nicht warum.

_________________
MDK 9.1, Kernel 2.4.21, KDE 3.1 Kylix 3 Pro (patched), nutze aber auch Windows
tomtom62
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278

WIN 2000, XP prof
D5 prof.
BeitragVerfasst: Sa 13.03.04 07:14 
Es wird daran liegen, dass diese ".." nicht aufgelöst werden können. Was Du tun willst, ist

Eine Verzeichnisebene höher gehen.

Dort in ein Verzeichnis tmp schreiben.

Davon abgesehen, dass dies sehr unüblich ist, wird es auch meiner Ansicht nach nicht nicht funktionieren.

Ich würde versuchen , das ".." vor dem Speichern aufzulösen und dann mit einem absoluten Dateinamen zu schreiben.

Beispiel: Das Programm liegt in /usr/local/programm/. Du möchtest Deine Datei schreiben nach ../tmp/dateiname.
also ist der absolute Pfad /usr/local/tmp/dateiname.

Dann sollte das gehen. (Vorausgesetzt, Du hast Schreibrechte im entsprechenden Verzeichnis)
Sven Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 314


D6 Ent, K3 Pro (patched)
BeitragVerfasst: Sa 13.03.04 10:57 
Die Schreibrechte waren nie das Problem.

Ich habe bisher immer am ende IOresult abgefragt, und auf die Fehlernummer geprüft.
Ungleich NULL = Fehler usw.
Wenn ich dies tue, bekomme ich natürlich eine Fehlermeldung.

Ich habe die Fehlerprüfung jetzt ausgeschaltet, und es geht. Die Datei wird in das Verzeichnis geschrieben.
Was mich jetzt dabei stutzig macht ist, das es einen Fehlercode gibt, jedoch die Datei trotzdem in das Verzeichnis
geschrieben wird. :?

_________________
MDK 9.1, Kernel 2.4.21, KDE 3.1 Kylix 3 Pro (patched), nutze aber auch Windows