home *** CD-ROM | disk | FTP | other *** search
- #include "stdafx.h"
- #include "cmdlearn.h"
- #include "doc.h"
-
- IMPLEMENT_DYNCREATE(CFileDoc, CDocument)
-
- BEGIN_MESSAGE_MAP(CFileDoc, CDocument)
- //{{AFX_MSG_MAP(CFileDoc)
- ON_COMMAND(ID_UPDATE_STATUS, OnUpdateStatus)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- CFileDoc::CFileDoc()
- {
- }
-
- CFileDoc::~CFileDoc()
- {
- }
-
- //////////////////
- // Open document: read status information.
- //
- BOOL CFileDoc::OnOpenDocument(const char* pszPathName)
- {
- CFile file;
- return file.Open(pszPathName, CFile::modeRead) ?
- file.GetStatus(m_status) : FALSE;
- }
-
- //////////////////
- // "Update status" command:
- // Re-open the doc. If changed or can't open, inform all views.
- // This command is sent by the frame when the timer goes off.
- //
- void CFileDoc::OnUpdateStatus()
- {
- CFileStatus old = m_status;
- if (!OnOpenDocument(GetPathName()))
- {
- // Couldn't open file (it was deleted): close all views
- UpdateAllViews(NULL, ID_FILE_CLOSE);
-
- } else if (memcmp(&m_status, &old, sizeof(old) - _MAX_PATH) != 0)
- UpdateAllViews(NULL);
- }
-