package com.avg.zaap.crashlibrary.offline.publisher.metadata;

import android.support.annotation.NonNull;

import java.io.File;

/**
 * This class serves as the default crash metadata helper.
 * <p/>
 * Created by marek.osvald on 29.7.2016.
 */
public class CrashMetadataHelper implements ICrashMetadataHelper {

    @Override
    public String getMetadataFileName(@NonNull File crashFile) {
        String crashFileName = crashFile.getName();

        int lastSeparator = crashFileName.lastIndexOf(EXTENSION_SEPARATOR);

        if (lastSeparator == NOT_FOUND) {
            return crashFileName + METADATA_EXTENSION;
        } else {
            return crashFileName.substring(0, lastSeparator) + METADATA_EXTENSION;
        }
    }

}
