SOL9 Sample: UrlCacheEntryStream

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * UrlCacheEntryStream.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */



// SOL9
// 2012/01/30

#include <sol/Locale.h>

#include <sol/wininet/UrlCacheEntryStream.h>


// Sample program to copy a cached local file to a current directory
//by using SOL::UrlCacheEntryStream class.

void _tmain(int argc, const TCHAR* argv[])
{
  if (argc !=2) {
    _tprintf(_T("Usage: %s UrlForTemporaryInternetFile\n"), argv[0]);
    _tprintf(_T("Ex: %s Cookie:to-arai@login.live.com/\n"), argv[0]);
    _tprintf(_T("Ex: %s vnd.ms.wmhtml://localhost/WMPfac47c03-cd93-4c48-b1c4-6a2091025c77.jpg\n"), argv[0]);
    return;
  }

  Locale locale;

  try {
    _bstr_t url = argv[1]; 
    
    UrlCacheEntryStream stream(url);
    _bstr_t fullPath;
    _bstr_t fileName;
    _bstr_t extension;

    if (stream.getLocalFileName(fullPath, fileName, extension)) {
      //If the cacheEntry for url has a localFileName, then copy the file to the current directory 
      _tprintf(_T("\n"));
      
      _tprintf(_T("LocalFile FullPath %s\n"), (const TCHAR*)fullPath);
      _tprintf(_T("FileName %s\n"), (const TCHAR*)fileName);
      _tprintf(_T("Extension %s\n"), (const TCHAR*)extension);

      _bstr_t saveFileName = fileName;

      if (stream.copy((const TCHAR*)saveFileName)) {
        _tprintf(_T("Copied a cached local file to %s\n"), (const TCHAR*)fileName);
      }
    }

  } catch (Exception& ex) {
    ex.printf();
  } catch (...) {
    printf("Exception\n");
  }
}

Last modified: 2 May 2016

Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.