MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / StartRead

Method StartRead

CrySystem/RefStreamEngine.cpp:111–159  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////// Starts asynchronous read from the specified file MT: Main thread only

Source from the content-addressed store, hash-verified

109// Starts asynchronous read from the specified file
110// MT: Main thread only
111IReadStream_AutoPtr CRefStreamEngine::StartRead (const char* szSource, const char* szFilePathPC, IStreamCallback* pCallback, StreamReadParams* pParams)
112{
113 unsigned nFlags = 0;
114 if (pParams)
115 nFlags = pParams->nFlags;
116
117 m_pPak->RecordFile( szFilePathPC );
118
119 // get rid of some jobs if there are too many in the queue
120 if (!(nFlags & SRP_QUICK_STARTREAD))
121 while (numIOJobs(eWaiting) >= m_nMaxQueueLength)
122 {
123 m_pLog->LogWarning("StreamEngine: The number of jobs waiting %d >= max queue length %d, waiting to free up the queue", numIOJobs(eWaiting), m_nMaxQueueLength);
124 UpdateAndWait(20, FLAGS_DISABLE_CALLBACK_TIME_QUOTA);
125 }
126
127 char szFilePathBuf[CCryPak::g_nMaxPath];
128 const char* szFilePath = m_pPak->AdjustFileName (szFilePathPC, szFilePathBuf, pParams && (pParams->nFlags & SRP_FLAGS_PATH_REAL) ? ICryPak::FLAGS_PATH_REAL: 0);
129
130 // first try to find such file; if it's already pending, add a client to it only
131 CRefReadStream_AutoPtr pStream;
132 NameStreamMap::iterator it = m_mapFilesByName.find (szFilePath);
133
134 if (it == m_mapFilesByName.end())
135 {
136 pStream = new CRefReadStream (szFilePath, this);
137 }
138 else
139 pStream = it->second;
140
141 // make sure that the permanent streams get locked in memory;
142 // if it's already locked, insert() won't do anything
143 if (nFlags & SRP_FLAGS_MAKE_PERMANENT)
144 m_setLockedStreams.insert (pStream);
145 else
146 if (nFlags & SRP_FLAGS_MAKE_TRANSIENT)
147 m_setLockedStreams.erase (pStream);
148
149 // at this moment the stream should self-register in this engine and the stream sets should get initialized
150 CRefReadStreamProxy_AutoPtr pProxy = new CRefReadStreamProxy(szSource, pStream, pCallback, pParams);
151
152 // register the proxy
153 AddIOJob (pProxy);
154
155 if (!(nFlags & SRP_QUICK_STARTREAD))
156 Update(0);
157
158 return (IReadStream*)pProxy;
159}
160
161// signals that this proxy needs to be executed (StartRead called)
162void CRefStreamEngine::AddIOJob (CRefReadStreamProxy* pJobProxy)

Callers 6

LoadAnimationMethod · 0.45
LoadMethod · 0.45
LoadFromCacheMethod · 0.45
StartIOJobsMethod · 0.45
LoadDialogMethod · 0.45
StreamCCGFMethod · 0.45

Calls 6

RecordFileMethod · 0.80
LogWarningMethod · 0.45
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected