Autor Beitrag
DSource
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 32



BeitragVerfasst: Fr 08.12.06 14:06 
Hallo!

Ich habe folgendes Problem. Meine Anwendung muss eine bestimmte, sehr grosse Log-Textdatei analysieren, während von einer anderen Anwendung (die ich nicht beeinflussen kann) in diese Datei geschrieben wird, teilweise zum gleichen Augenblick. Ich habe probiert, meine Anwendung auf Lesezugriff zu beschränken (fmOpenRead), sowohl mit TFileStream als auch mit TextFile/AssignFile, zuweisen von fmOpenRead Filemode und Reset - nichts funktioniert. Sobald ich die Datei geöffnet habe, kann die andere Anwendung nicht mehr schreiben (einfach zu testen, einfach Notepad aufmachen (selbe Datei) und dann speichern versuchen während FileStream oder TextFile offen sind - funktioniert nicht).

Ich bin sehr dankbar für jede erdenkliche Hilfe, leider hat Forensuche und Google nicht wirklich was gebracht. Also, Kernfrage: Wie kann ich eine Textdatei zum Lesen öffnen, während andere Anwendungen gleichzeitig in die Datei schreiben können?

Danke!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Fr 08.12.06 14:13 
Moin!

Ich fürchte, das wird an dem Modus liegen, in dem die andere Anwendung die Datei öffnet - wenn du allerdings keinen Einfluss darauf hast, dann... tja... :? wird das wohl nix, IMHO. :(

Bleibt dann nur, das am Dateisystem vorbei zu machen - und ob das den Aufwand wert ist? :gruebel: :|

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
DSource Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 32



BeitragVerfasst: Fr 08.12.06 14:15 
Naja, ich bezweifel das, denn wenn ich das ganze mit NOTEPAD teste funktioniert es genauso nicht. (Also Datei öffnen mit meiner Anwendung, dann Datei öffnen mit Notepad (geht), aber Speichern mit Notepad geht nicht).

Aber wie auch immer, jeder Weg ist mir recht, ich muss nur eine Lösung finden, egal wie kompliziert. Was ist dein Vorschlag in Bezug aufs Dateisystem?
wolke
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 240



BeitragVerfasst: Fr 08.12.06 14:25 
ganz primitiv: wie wärs mit kopieren der datei und auslesen der kopie?
Tris
Hält's aus hier
Beiträge: 1



BeitragVerfasst: Di 12.12.06 19:33 
Versuch mal
ausblenden Delphi-Quelltext
1:
FileOpen('log.txt', fmOpenRead or fmShareDenyNone);					

Hoffe damit klappts.


Zuletzt bearbeitet von Tris am Mi 13.12.06 07:18, insgesamt 1-mal bearbeitet
wolke
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 240



BeitragVerfasst: Di 12.12.06 19:59 
wenn es gar nicht anders klappt, könntest du dich mit volume shadow copy beschäfigen. einfach ist das aber nicht. :)

damit kannst du von dateisystemen sogenannte "schattenkopien" (= snapshots) erstellen. auf diesem volume entsprechen dann alle dateien dem zustand zum zeitpunkt des snapshots.

Zitat:
Applications that are running often keep their files open continuously. For backup, this can present a problem because this prevents backup applications from accessing and copying these files to backup media. Even if an application does not have its files open, it is possible—because of the finite time needed to open, back up, and close a file—that files copied to the backup media might not all reflect the same application state at the same point in time.

Additionally, backing up servers that are running critical applications such as databases or messaging services presents a unique challenge. These applications run in a volatile state as a result of extensive optimizations that deal with huge flows of transactions and messages. Because these applications keep their data in a constant flux between memory and disk, it is difficult to pinpoint the data that needs to be archived. The most straightforward solution is to interrupt the application during backup, which puts the data into a stable state, but might result in unacceptable amounts of downtime, particularly if the applications are large.

For both problems, the Volume Shadow Copy Service provides a solution by enabling a snapshot of the data at a given point in time, while minimizing the interruption to applications. This can involve cooperation from the applications, so that they can notify the operating system that they are briefly quiescing their data for archival. During quiescence, applications make data on the disk consistent. For example, an application might flush its buffers to disk or write out in-memory data to disk.