#include "../stdafx.h"
#include "CreateStream.h"
#include "common/windows/FOutStream.h"
#include "common/posix/FInStream.h"
#include "androidlog.h"
#define LOG_TAG "CreateStream"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>


extern const char* __progname;

namespace NS_Logging
{
    static const std::string S_logFilePath("/data/data/com.funambol.omadmclient.android.service/Logs/");
    static const std::string S_commonLogFile("OMA_DM_Client.log");
    static const std::string S_dataPath("/data/data/");
    static const std::string S_logPath("/files/Logs/");

    NS_DM_Client::NS_Common::IOutStream* CreateOutStream()
    {

        NS_DM_Client::NS_Common::FOutStream* stream = new(std::nothrow) NS_DM_Client::NS_Common::FOutStream();

////        stream->Open((S_logFilePath + S_commonLogFile).c_str());

        std::string logFilePath = S_dataPath + std::string(__progname) + S_logPath + S_commonLogFile;
        LOGI("logFilePath:%s",logFilePath.c_str());
        stream->Open(logFilePath.c_str());
        return stream;
    }

    NS_DM_Client::NS_Common::IInStream* CreateInStream()
    {
        return new(std::nothrow) NS_DM_Client::NS_Common::FInStream();
    }

}
