Feature #1664

Updated by Zbigniew Rebacz about 7 years ago

Buffer should also offer alternative method (Get) to ~operator that returns raw pointer.

The size could also be remembered and we should introduce Count() and IsEmpty() approach.
Something like:
<pre>
dword length = ::GetShortPathName(static_cast<LPCTSTR>(path), nullptr, 0);
if(length == 0)
return path;
Buffer<char> shortPathBuffer(length);
</pre>

Could be easily refactor to:
<pre><code class="cpp"> &lt;pre&gt;
Buffer<char> GetBufferForShortPath(const String& path)
{
dword length = ::GetShortPathName(static_cast<LPCTSTR>(path), nullptr, 0);
return Buffer<char> shortPathBuffer(length);
}

// The in the code:
Buffer<char> shortPathBuffer = GetBufferForShortPath(path);
if (shortPathBuffer.IsEmpty())
return path;
else
// Do something with the buffer...
</code></pre> &lt;/pre&gt;

Back