function clouddir = getCloudFolder()
% getCloudFolder Gets the folder that contains your cloud storage area.
%
% clouddir = getCloudFolder returns a string which is the folder that 
% contains your cloud storage area. 
% 
% If your cloud storage area is not available, getCloudFolder returns an
% empty array.
%
%
% Example: Read a file from cloud storage
%
% Assume that the cloud storage area contains a text file called data.txt
% in a folder called resources. Note that this will only work on a machine 
% with access to cloud storage. 
%
% % Find the cloud storage folder
% cloudFolder = parallel.internal.cloud.getCloudFolder
% % Find the location of the data file
% datapath = fullfile(cloudFolder, 'resources', 'data.dat');
% % Read the data in the file
% text = fileread(datapath);
%
% See also parallel.internal.cloud.uploadToCloud,
%          parallel.internal.cloud.addCloudFolderToPath

    % The location of the cloud storage area is stored within a well known
    % file located in MATLAB's temporary folder with the name
    % 'MATLAB-cloud-storage-location'
    wellknownfile = fullfile(tempdir, 'MATLAB-cloud-storage-location');
    
    % If the well known file exists, read it's content. Otherwise, 
    % return empty. 
    if exist(wellknownfile, 'file')
        clouddir = strtrim(fileread(wellknownfile));
    else
        clouddir = [];
    end
end